Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can an extension object detect and block a tab change?

I have an extension object that (based off selection in QlikView) reads a string from the database, allows the user to alter that string and then store it back to the database. Inside the extension object I have validation in place where if a user changes values of some of the controls inside the extension object I prompt them to check if they want to save their changes before.

The problem is that if a user changes tabs and comes back the extension object refreshes and thus loses the changes they may have made.

Is there a way for an extension object to detect a tab change and potentially block the tab change? Or maybe a different route, is there a way to make the extension object NOT refresh on a tab change, so it just retains the changes they might be in the middle of making?

11 Replies
IAMDV
Luminary Alumni
Luminary Alumni

James,

I have seen this behaviour with extension objects. I think this happens because "Page Load" action is triggered everytime you toggle between the tabs. I need to write custom JavaScript which remembers the selection state and probably you should disable the sheet tabs, instead use the buttons which triggers the actions to make the selections.

Good luck!

Cheers,

DV


www.QlikShare.com

Not applicable
Author

You say you've see this behavior. Which one? The block of a tab change? Or the remembering of the state across tab changes?

I doubt my team would go for getting rid of the tabs. Another team developed out QVWs and I am just working on a few extension objects to expand functionality.

IAMDV
Luminary Alumni
Luminary Alumni

It's the former.

Not applicable
Author

Anybody have an idea how this would be done?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

My I-have-not-coded-this wild guess would be to use a Document Extension that adds a listener for the Tab click events. And then in your callback decide whether to percolate to the other listeners or not. Not when you have some sort of pending state that you want to force the user to complete.

-Rob

Not applicable
Author

Just getting back to this.

What exactly is the difference between a Document Extension and an Extension Object? I see FireBug as the only listed Document Extension on my setup, and I have multiple extension objects installed, so it seems there is a difference but I can't find much documentation on it.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

An Object Extension is a screen object that is typically used to visualize data, like drawing a chart. It fetches data from the QV engine, but typically does not interact with the DOM outside it's own <div>.

A Document Extension is intended to add or modify overall document behavior, typically by modifying the DOM to add elements or change the properties of CSS elements. A Document Extension does not have a visual representation on the screen, although it may create visual elements.

The extension type is specified in the definition.xml file by the Type="document|object" attribute.

Here is a brief introduction to the two extension types.

http://www.qlikfix.com/2012/07/03/qlikview-extension-tutorials-documentation-and-examples/

-Rob

http://masterssummit.com

http://robwunderlich.com

Not applicable
Author

Ah. Thank you! That should help me get to wear I need to go.

The solution I had developed this morning was based around jquery and the structure of the tabs in the QVW:

//All tab clicks are based in a anchor

$('a').click(function(event){

     //First see if this event has a parent

     var _parentNode = event.target.parentNode;

     if(_parentNode)

     {

          //It it's parent is an a (anchor) and it has a parent, then that means we need to go up one level to the li (list item)

          if((_parentNode.tagName.toLowerCase() == "a") && (_parentNode.parentNode))              

               _parentNode = _parentNode.parentNode;


          //If we have a node and it is a li (list item)

          if(_parentNode && (_parentNode.tagName.toLowerCase() == "li"))

          {
               var _ul = _parentNode.parentNode;

              

               //Ensure that the list item we are dealing with is within the tabs ul collection

               if(_ul && _ul.className && (_ul.className == "qvtr-tabs"))

               {
                    //Then check to see if it's class is anything other than "selectedtab", this means we are clicking off the current tab

                   if((!_parentNode.className) || (_parentNode.className != "selectedtab"))

                    {
                        
//If we are here it means that we are attempting to navigate away from the selected tab, to another tab

                         //So we need to check the dirty flag of this extension object (if it exists) to see if we want to allow the change or prompt the user to save.

                     }

               }

          }

     }

});

Not applicable
Author

Also when you say "use a Document Extension that adds a listener for the Tab click events" do you mean just how I've done above? By hooking into the anchor click that fires off the tabs? Or is there a specific QV API call for Tab Clicks? I am looking through the docs and I don't see one.