# Can TabStrip pass parameter to window?

**URL:** <https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431>\
**Category:** Ignition\
**Created:** [May 9, 2014, 3:05pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431 "2014-05-09T15:05:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![george](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/george/32/14066_2.png) [@george](https://forum.inductiveautomation.com/u/george)\
**Post date:** [May 9, 2014, 3:05pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/1 "2014-05-09T15:05:42Z")

</div>

I have a standard navigation window with the TabStrip on it, working fine.

I now want to add tabs for different production lines on it, e.g.  
Line 1  
Line 2  
Line 3  
Line 4  
Line 5

However ideally I just want to create a single window for a Line and have a custom  
property on it that is the Line Number.

Is there any way for the Tab Strip component to be able to display my common window but pass  
the appropriate parameter to it?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 9, 2014, 4:51pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/2 "2014-05-09T16:51:27Z")

</div>

Short answer: yes. Long answer: yeeeessssss… Sorry, long day. I’m getting loopy… ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")

Anyway, here’s a sample project:  
[attachment=0]TabbedSingleWindow (2014-05-09).proj[/attachment]

This is a v7.2 project, so in case it doesn’t import for you, here’s an explanation.

I did this by disabling the Navigation Mode on the Tab strip, then putting this property change script instead:

```auto
system.nav.swapWindow("Window 1","Window 1",{"LineNumber" : event.source.selectedTab})
```

swapWindow works just like swapTo, except you can specify what windows to swap, along with parameters. I just swap the same window. 🙂

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [May 9, 2014, 4:56pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/3 "2014-05-09T16:56:18Z")

</div>

Try this:

Change your tab strip so its [navigationMode](http://inductiveautomation.com/support/usermanuals/ignition/buttons_pmitabstrip.htm) is Disabled  
Add the following code to the mouseClicked event of the TabStrip  
(NOTE: this only works for up to 9 lines)

```auto
sWinName = event.source.selectedTab
ds = system.dataset.toPyDataSet(event.source.tabData)

for row in ds:
	if row["NAME"] == sWinName:
		iLineNumber = int(row["DISPLAY_NAME"][-1:])
		#print "system.nav.swapTo(" + sWinName + ", {\"LineNumber\": " + str(iLineNumber) + "})"
		system.nav.swapTo(sWinName, {"LineNumber": iLineNumber})
		
```

EDIT:

I just noticed Jordan’s code and realized a flaw in my code.

You want to open the same window, but the Tab Strip Customizer forces the name of the tab to be the window you want to open. When you make all three the same name, my code will not work and it will look like all tabs are pressed. I think the best thing thing to do is include the line number as part of the name and then postfix the number to past through. So if the window to open is LineWindow then each tab name would be: LineWindow1, LineWindow2, LineWindow3… and you would use this code:

```auto
sWinName = event.source.selectedTab

iLineNumber = int(sWinName[-1:])
sWinName = sWinName[:-1]
#print "system.nav.swapTo(" + sWinName + ", {\"LineNumber\": " + str(iLineNumber) + "})"
system.nav.swapTo(sWinName, {"LineNumber": iLineNumber})

```

---

<div class="post-metadata">

**Author:** ![george](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/george/32/14066_2.png) [@george](https://forum.inductiveautomation.com/u/george)\
**Post date:** [May 9, 2014, 9:23pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/4 "2014-05-09T21:23:39Z")

</div>

Thank you both. I will try your suggestions next week.

I did think it might involve changing the navigation mode and putting in the script manually.

---

<div class="post-metadata">

**Author:** ![george](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/george/32/14066_2.png) [@george](https://forum.inductiveautomation.com/u/george)\
**Post date:** [May 13, 2014, 11:13am UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/5 "2014-05-13T11:13:14Z")

</div>

Jordan - this might be a silly question but can I ask why you’ve used swapWindow rather than swapTo?

My situation is complicated slightly by the fact that there will be some tabs that will simply go to windows and other tabs that will be Line 1, Line 2, Line 3 etc. I believe I should be able to handle this by looking at the selectedTab property.

My only other issue is if someone switches windows without using the navigation bar (I have an option on a summary screen to double click and it jumps automatically to a detail screen).  
By default, the selected tab would now not be correct.

I’m therefore looking at putting something in the internalFrameActivated script on a window to say

```auto
system.gui.getWindow("Nav").rootContainer.getComponent("Tab Strip").selectedTab= <<window name>>
```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 13, 2014, 3:45pm UTC](https://forum.inductiveautomation.com/t/can-tabstrip-pass-parameter-to-window/8431/6 "2014-05-13T15:45:42Z")

</div>

> [@george](#):
>
> Jordan - this might be a silly question but can I ask why you've used swapWindow rather than swapTo?

Sure! They both work in similar fashion, but swapWindow will let you swap any window, not just the 'main' one.
