372
Views
5
Comments
Solved
How to get the tab index of a tab
Application Type
Reactive

Hi! 

My application tabs are dynamic, meaning that the tab index changes depending on the condition.

How can I get the tab index of a specific tab if the tab index is dynamic?


I've tried doing this 

$parameters.TabIndex = document.getElementById($parameters.TabHeaderId).tabIndex;


But it does not return the tab index



Regards,

Andi

2025-07-13 11-31-16
Doctor
Solution

Actually, I have found another way.

I gave each tabitem header a specific class that only it has.

Then I used this Javascript:

$parameters.TabIndex = document.getElementsByClassName($parameters.TabCLass)[0].getAttribute("data-tab");


It returns a text. You just have to convert from text to integer

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Andi,

can you elaborate on what exactly you are trying to do.  

In what way is it dynamic ? based on a list or some other way ?

Where exactly do you need this tabindex.  I just tried with a list, and there's 2 places you do something with a tabindex : the startingTab property of the tabindex widget, and the ActiveTab input into the OnTabChange event.  

Which one of these do you have a problem with ? 

Dorine

2023-10-21 19-42-11
Tousif Khan
Champion
2018-10-29 08-31-03
João Marques
 
MVP

Hi Andi,


You can very easily find out this with JavaScript:

Basically, OutSystems UI tabs, will have the headers with elements identified with class osui-tabs__header_item (see below an example of three headers) and the active one will have the osui-tabs--is-active class. 


The JavaScript snippet loops each of the headers and returns the (zero-based) position of the active one.


Kind Regards,
João

2020-01-08 08-43-00
Rahul Kumar

Hi Andi, 


You can use OnTabChange event. It will give you the active tab index number and you can store that value in local variable. Use that Local Variable value wherever you need. 


I am just elaborating Dorine OnTabChange line. 

Thanks and Regards,

Rahul Kr.

2025-07-13 11-31-16
Doctor
Solution

Actually, I have found another way.

I gave each tabitem header a specific class that only it has.

Then I used this Javascript:

$parameters.TabIndex = document.getElementsByClassName($parameters.TabCLass)[0].getAttribute("data-tab");


It returns a text. You just have to convert from text to integer

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.