How to navigate between tabs on Button click using Handler?

Hello Community,

I would like to switch tabs based on a user action using code in a handler. Is it possible to write code that opens a custom tab on the same page, as shown in the figure below?

On button click, I have implemented below code in the handler, but it is not working.

{
        request: "crt.OpenTab",
        handler: async (request) => {
            request.$context.set("SelectedTab", "CustomTab");
            request.$context.set("ActiveTab", "CustomTab");
            request.$context.profile.set("Tabs_SelectedTabIndex_Profile", 2);
        return true;
     }

}

Best regards,

Ajay Kuthe

Like 2

Like

4 comments
Best reply

The attribute you need to set is the [TabControlName]_SelectrdTabIndex_Profile. If you tab control is named "TabPanel_fb0xrup", then the attribute you would set would be:

// select first tab
request.$context.TabPanel_fb0xrup_SelectedTabIndex_Profile = 0;

Note, the indexes are zero based.

Ryan

The attribute you need to set is the [TabControlName]_SelectrdTabIndex_Profile. If you tab control is named "TabPanel_fb0xrup", then the attribute you would set would be:

// select first tab
request.$context.TabPanel_fb0xrup_SelectedTabIndex_Profile = 0;

Note, the indexes are zero based.

Ryan

Also, to clarify, there is no "set" method in Freedom UI pages like there was in classic pages. You will just set and read values from the attributes directly as normal variables.

Ryan Farley,

Yes, it works fine.

However, how can I get the index of a particular tab using the Element code in the context? #FreedomUI

Ajay,

I am not sure there's a way to get the index at runtime, if there is I've not seen anything yet, but it's possible it's buried somewhere in the $context.

Show all comments