I'm using the Navigation\Tabs widget and want to set the ActiveTab based on the previous tab.
The challenge is that the ActiveTab property expects the text name of the tab as used in the DataTab property. But, the OnTabChange event passes the integer tab number.
To set the ActiveTab correctly, I needed to use a switch in the Preparation, which seems a very brittle approach. Is there a better way?
I am not sure I fully understand what you are trying to achieve, could you describe it further. Have you tried naming the data tab "1","2", "3", "4"...
You could also have a local variable called where you assign the activetab or the tab you want to go to next.
If this is a flow you should also look at the wizard might be a better option
I'll try to clarify.
I created an OnTabChange handler. It was automatically passed the CurrentTab number (0, 1, 2, ...) I assign that number to a session variable.
In my Preparation, I want to go to the tab I stored in the session variable. To do this I needed to use a switch to translate: 0 -> "address-tab", 1 -> contact-tab, etc.
Looking at your suggestions:
- Have you tried naming the data tab "1","2", "3", "4"...
I could, and that would remove the need for a switch - but the solution would be just as brittle, if I reorder the tabs, I'll need to also change all the DataTabs
- You could also have a local variable called where you assign the activetab or the tab you want to go to next.
The question is, how do I determine the ActiveTab? The OnTabChange event is passed the tab number - is there a function that will allow me to retrieve the associated DataTab value?
- If this is a flow you should also look at the wizard might be a better option
What wizard is there and how do I invoke it?
I know your expertise on this. I must say we should have an online discussion on this. Writing only comments will close the discussion straight away! And will restrict the benefits from this information.
t rex game
Hi,
didn't have time yet to test this out, and it's a bit convoluted, but you could add a hidden input to your screen, and have an extended onclick property on each tab header setting that input value in javascript
I have to go now, but if you don't get what i mean, let me know, i'll work out a demo this afternoon
Dorine
How about you assign an input parameter, would this work?
André P wrote:
Hi Andre,
I can't get that to work, I don't think it works both ways, you can use it to set the initial tab on rendering the screen, but when changing tabs, the variable doesn't get updated...
I tried this and it seems to work. I am trying to find out how exactly:
Thanks for all the replies. In the end, I went with a different approach. Not sure it's the best way, but certainly less brittle.
1. I created a hidden input and a hidden button (with class names of active-tab-input and active-tab-button respectively.
2. I set the ExtendedClass for the Navigation\Tabs widget to "customer-tabs". (I discovered that in the generated html, this control has the attribute data-active-tab set to "tab-"+ActiveTab).
3. In the OnTabChange event handler, I added a RunJavaScript action with the following script:
"$('.active-tab-input')[0].value = $('.customer-tabs')[0].getAttribute('data-active-tab').substring(4); $('.active-tab-button')[0].click();"
4. In the screen action for the button click, I assigned a session variable to the input value. This session variable is used in the preparation to set the active tab.
So, it all seems to work. Pity there's not a more built-in way of doing it.