# Separating Pens on the Selection of Dropdown Labels

**URL:** <https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183>\
**Category:** Ignition\
**Created:** [January 29, 2019, 1:00pm UTC](https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183 "2019-01-29T13:00:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saurabhambildhuke08](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saurabhambildhuke08](https://forum.inductiveautomation.com/u/saurabhambildhuke08)\
**Post date:** [January 29, 2019, 1:00pm UTC](https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183/1 "2019-01-29T13:00:25Z")

</div>

Hii,  
I would like to create drop down list, that will have 6 or more labels but not constant. Each label corresponds to a group of tags. I would then link the labels to the Easy chart. I can enter the labels manually.  
However, I would like to know if it is possible to write some script to populate the drop down menu.  
I want to know if i am selecting one label from drop down list then based on the label there are certain tags associated with labels which need to be shown in easy chart. same for the other labels  
Awaiting your response…

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 29, 2019, 1:58pm UTC](https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183/2 "2019-01-29T13:58:21Z")

</div>

> [@saurabhambildhuke08](#):
>
> I would like to know if it is possible to write some script to populate the drop down menu.

Yes. You can use the [runScript()](https://docs.inductiveautomation.com/display/DOC79/runScript) expression function in a binding to call a script function that returns the dataset you want. You can use the [system.dataset.toDataSet()](https://docs.inductiveautomation.com/display/DOC79/system.dataset.toDataSet) script function to construct that dataset from a python list of lists (the inner lists being the rows).

> [@saurabhambildhuke08](#):
>
> based on the label there are certain tags associated with labels which need to be shown in easy chart

The pens to be displayed on an [EasyChart](https://docs.inductiveautomation.com/display/DOC79/Easy+Chart) can be selected by supplying datasets to its `pens` and `tagPens` properties. You could keep a table in your database that contains the lists of pens that correspond to the keys in your dropdown dataset. Then the EasyChart properties could have query bindings that include your dropdown's selected key.

---

<div class="post-metadata">

**Author:** ![saurabhambildhuke08](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saurabhambildhuke08](https://forum.inductiveautomation.com/u/saurabhambildhuke08)\
**Post date:** [January 30, 2019, 6:33am UTC](https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183/3 "2019-01-30T06:33:51Z")

</div>

Sir, Could you elaborate more on the scripting section. I have tried to build a script as name FillChart

def filldropdown(GroupNo):  
import system  
header = [“values”,“path”]  
data = []  
temp = [1,2,3,4,5,6,7]  
tag = []  
if GroupNo == ‘1’:  
tag = temp  
else:  
for i in range(7):  
tag[i] = temp[i] + (GroupNo-1) \* 7  
for j in range(7):  
data.append([“Tag %i”%(tag[j]), “Path/Tag%i”%(tag[j])])  
return system.dataset.toDataSet(header,data)  
I have linked the run script to tag Pens Binding property as : runScript(“app.chart.fillChart(” + {Root Container.Dropdown.selectedValue} + “)”, 0)

---

<div class="post-metadata">

**Author:** ![saurabhambildhuke08](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@saurabhambildhuke08](https://forum.inductiveautomation.com/u/saurabhambildhuke08)\
**Post date:** [January 30, 2019, 12:21pm UTC](https://forum.inductiveautomation.com/t/separating-pens-on-the-selection-of-dropdown-labels/22183/4 "2019-01-30T12:21:49Z")

</div>

> [@pturmel](#):
>
> You could keep a table in your database that contains the lists of pens that correspond to the keys in your dropdown dataset.

How could i do that...
