Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jcamps
Partner - Creator
Partner - Creator

Variables, Triggers and the Back button

Hi,

In my QVW, I'm using a trigger event to change the value of a variable when the selection changes. So, when I make a selection, the event triggers and the variable changes. So far, so good. My problem is with the back button: the first time I click on BACK the variable rolls back, and I need a second "Back" click to undo the original variable. This is not acceptable since the variable value is related to the selection, and a single "back" leaves an incorrect state.

A simple attached xample might help:

     - field MYFIELD, values 1,2,3

     - variable MYVAR

     - Objects: MYFIELD Listbox, and MYVAR Textbox.

There is a ONSELECT trigger on Myfield, that sets MyVar as "=10*Myfield".

First, select "1" on MyField. the event triggers and sets the MyVar as 10*1... so the TextBox displays "10".

Repeat with "2", same logic and the TextBox displays "20".

So far, so good.

BUT, if I click "back", the VAR is rolled back to "10" BUT NOT the Field. This results in having on-screen the value "2" still selected, but the textbox displays "10"..... obviously, not 10 times the selected value

I dont know how to avoid the "variable change" being inserted in the "back pile". Any other workaround would be also apreciated.

Note that I know i could set MyVar directly as an expression so that it evaluates automatically, without a trigger. The problem is, this formula is very complex, and the same value is used over 50 times in a single sheet. For some reason QV does not cache the result, so it is evaluated 20 times in a single tab making the sheet unusable.

12 Replies
hoodhill
Partner - Contributor II
Partner - Contributor II

Hi.

I don't see why you're using a trigger in this instance, why not just set the MyVar variable to '= MyField * 10'. You can then get rid of the trigger and once done the back button works (as it's backing out the last change).

jcamps
Partner - Creator
Partner - Creator
Author

This was just a simple example...

Real use scenario would be, I have a large set of selections in a tab. Some are on screen (most common, like "YearMonth" or "Brand"), others appear / popup on demand when user clicks on "More selections" (more rarely used, say "YearWeek"). What I do, create the "popup" objects with visibility based on a variable, say vPopupEnabled, plus a button that switches that variable back and forth between 1 and zero.

What the user does (just an example)

* Select in YearMonth

* ...

* Click on "Open selections"

* Select on YearWeek

* Click on "Close selections"

* Click on "Open selections"

* Change YearWeek

* Click on "Close selections"

* Switch to a different TAB where there are no popup selections

* Select on Brand

Now, if the user clicks on "Back", he'd expect to navigate back his selections. What he sees is as he clicks on "back":

  1. OK, remove selection on Brand
  2. Does nothing (!!)
  3. Back on YearWeek
  4. Nothing again (!?!)
  5. Nothing again (@#@!!)
  6. Mmmmm, WTF... let me switck back to the other tab. Oh well, what's the popup doing open now?

Hope that's clearer...

jerrysvensson
Partner - Specialist II
Partner - Specialist II

We use the extension HideIt and remove the Back/Forward/Clear buttons. Problem solved in Ajax.