Cannot change a Navigation Tab via an event

I have an app that is utilizing a Tab navigation component (not a Tab Container), and it seems there is no way to explicitly set the selected tab and show the Tab selected on the UI.

The Tab Container provides such methods (e.g. setCurrentViewIndex), but not the Tab navigation component. The closest thing that the Tab component has is setValue which does it's job but will not show the set tab as selected in the UI.

I'm using Navigation Tabs because it can be connected to a data source, which is a feature I need. The Tab Container doesn't seem to allow this.

Is there something I'm missing? Can we expect more methods for this component in the future? Any plans to allow Data Source to Tab Container?

Thanks in advance.

For example, here is a sample app where the Tabs are defined.

A text field show the selected tab value.
image
image

This is what happens when I click the button to set the Tab to the second tab
image

As a work-around, I've discovered that I can maintain a (hidden) text input field to hold the Tab value, populate that field based on my system logic, and then map the Default Value of the tab to this value.

So to set the Tab, I just need to populate this input field. Works like a charm, but would love for there to be a more straight forward way.

Thanks.

Hey Mark!

First, awesome workaround. I had to do a similar hidden type thing for setting pagination values so it's neat to see others finding creative ways to get things done.

Second, have you tried to get the value property out from the tabs.data array? I was able to map these using a variable array with a name property like this:

image

...and used that as the source for my Tab component:

image

After that, the button is able to call upon the value of the data to use by name, which seems to trigger the UI to update the active tab:

6C291582-5276-4AB7-A445-3E1D6022F87C

Depending on how you are setting up these buttons, I am pretty sure you can target whatever you need once you know the index/key.

Thanks, pyrho. After looking at your code, I realized that I was setting the value to the value of the Label. Setting the value to the value of "Value" works as expected.

Regrettably, I was doing it wrong, but fooled because the tab was getting selected in some regard because I was seeing UI experience as if the tab was selected in the background. I should have shown my button's event code.

I will select your explanation as the Solution. Thanks again.

1 Like