# Tab Strip Dataset Expression - Get Selected Tab Index

**URL:** <https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972>\
**Category:** Ignition\
**Tags:** vision, ignition81\
**Created:** [October 3, 2023, 2:00pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972 "2023-10-03T14:00:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 3, 2023, 2:00pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/1 "2023-10-03T14:00:39Z")

</div>

I want to use an expression binding on the dataset of a tab strip. Why is the tab data not exposed to the expression binding editor?

I'm trying to get the "tab index" for the selected tab. Any thoughts?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 3, 2023, 2:41pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/2 "2023-10-03T14:41:02Z")

</div>

Add a custom property to your tab strip called 'selectedTabIndex.'

Then, use a propertyChange script to set the index any time a different tab is selected. You could then bind anything you want to the custom property.

The script would look something like this:

```auto
# Made for the propertyChange event handler of the tab strip
# Only fire the script if the selected tab property changes
if event.propertyName == 'selectedTab':

	#Retrieve the tabData dataset
	tabData = event.source.tabData

	# Iterate through the dataset to look for the matching tab
	for row in range(tabData.rowCount):

		# Define the selected index property as the row in the dataset where the newly selected tab is found
		if event.newValue == tabData.getValueAt(row, 0):
			event.source.selectedTabIndex = row
			break

```

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 3, 2023, 2:43pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/3 "2023-10-03T14:43:24Z")

</div>

I'm using a couple different tab strips and showing/hiding them conditionally.

Would adding an "or visible" to the property change script work?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 3, 2023, 2:46pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/4 "2023-10-03T14:46:33Z")

</div>

> [@amarks](#):
>
> showing/hiding this conditionally

I'm not sure what this means. Are you toggling the bool for the `hidden` column on some of the tabs?

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 3, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/5 "2023-10-03T14:47:25Z")

</div>

The visible property for the entire tab strip

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 3, 2023, 2:57pm UTC](https://forum.inductiveautomation.com/t/tab-strip-dataset-expression-get-selected-tab-index/79972/6 "2023-10-03T14:57:39Z")

</div>

If you need to trigger something off of a visibility property change, it will be this:

```auto
if event.propertyName == 'visible':

```

...but if you are simply trying to show or hide a tab strip when a certain tab is selected, then you could do it all from the propertyChange script. That script would look more like this:

```auto
# Only fire the script if the selected tab property changes
if event.propertyName == 'selectedTab':
	if event.newValue == 'tabName':
		# Toggle visibility off using the tab strip's visible property
		
	else:
		# Toggle visibility on using the tab strip's visible property

```
