# Multiple selection in table then input same result

**URL:** <https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684>\
**Category:** Ignition\
**Created:** [October 28, 2015, 3:48am UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684 "2015-10-28T03:48:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![trishhiyah](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@trishhiyah](https://forum.inductiveautomation.com/u/trishhiyah)\
**Post date:** [October 28, 2015, 3:48am UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/1 "2015-10-28T03:48:13Z")

</div>

Hi, is it possible in a table to select multiple row then input same result(drop down list) with the selected row in this table.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f0984456f8dd47c5beb0a68b72c3d6cf62ef2aa.jpeg)

Thank you so much

---

<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:** [October 28, 2015, 2:52pm UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/2 "2015-10-28T14:52:27Z")

</div>

Hmm. Interesting. The view() function in my [Simulation Aids](http://marketplace.inductiveautomation.com/moduledetail?moduleId=93) module can extract a subset of the table data based on the selectedRows property of the table. However, that property isn’t bindable, so it’s hard to make the view function update as the selection changes. Try this expression on your Dropdown’s data property:`view("Select WO_, Product_Type Where _r in binding.target.parent.getComponent('Table').selectedRows",
  {Root Container.Table.data},
  {Root Container.Table.selectedRow})`Including ‘selectedRow’ in the list of arguments will make the result update as the first selected row changes. It’s not immediately obvious how to make this work overall.  
{Put this expression on the data property of a second table if you want to see it’s operation more clearly.}

---

<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:** [October 28, 2015, 3:04pm UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/3 "2015-10-28T15:04:17Z")

</div>

One thing I’m not clear on: is the drop down list part of the table or is it a separate component?

---

<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:** [October 28, 2015, 3:07pm UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/4 "2015-10-28T15:07:17Z")

</div>

Add this code to your table’s mouseReleased event:`dropdown = event.source.parent.getComponent('Dropdown')
system.db.refresh(dropdown, 'data')`It’s not documented, but system.db.refresh() isn’t limited to database queries – any binding will update. With this and the above, the dropdown’s dataset will update as you highlight rows from high to low, and will update when you release the mouse after highlighting rows from low to high.

---

<div class="post-metadata">

**Author:** ![trishhiyah](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@trishhiyah](https://forum.inductiveautomation.com/u/trishhiyah)\
**Post date:** [October 29, 2015, 3:59am UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/5 "2015-10-29T03:59:03Z")

</div>

The Drop down list part in Table which is a column result, with the list of passed or failed.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f0984456f8dd47c5beb0a68b72c3d6cf62ef2aa.jpeg)  
What I did now is I added a two button which is passed and failed, once the user select multiple row then click the button passed. all the selected Work order will have a passed result.

my code in a passed button:

[code]import sys

selectedRow = event.source.parent.getComponent(‘Table’).selectedRow  
selectedRows = event.source.parent.getComponent(‘Table’).getSelectedRows()

table = event.source.parent.getComponent(‘Table’)  
data = event.source.parent.getComponent(‘Table’).data  
RecordID = str(event.source.parent.RecordID)  
WO\_Num = str(data.getValueAt(selectedRow, “WO\_Num”))  
LabTimeOut = str(event.source.parent.getComponent(‘TimeL’).text)  
Remarks = str(data.getValueAt(selectedRow, “LabComment”))  
system.db.runUpdateQuery(“UPDATE OT\_Trolley\_Allocation SET Status = ‘Passed’, LabComment = '”+ Remarks +"’ WHERE WO\_Num = ‘" + WO\_Num + "’")  
system.db.runUpdateQuery(“UPDATE OT\_Allocation\_Status\_History SET LabOut = '”+LabTimeOut+"’, LabResult = ‘Passed’, LabRemarks = ‘"+ Remarks +"’ WHERE WO\_Num = ‘" + WO\_Num + "’ and RecordID = ‘"+ RecordID +"’")[/code]

but only one row has been changed, one last selected work order has a passed result if I click the button.

---

<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:** [October 29, 2015, 10:24am UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/6 "2015-10-29T10:24:58Z")

</div>

All right then!

You need two things.

First, iterate through the selectedRows and build a list of work orders.  
Second, change the update queries to use this list.

[code]import sys

selectedRow = event.source.parent.getComponent(‘Table’).selectedRow  
selectedRows = event.source.parent.getComponent(‘Table’).getSelectedRows()

WO\_List = []  
for row in selectedRows:  
WO\_List.append(str(data.getValueAt(row, “WO\_Num”)))

#remove brackets  
WO\_Num = str(WO\_List[1,-1])

table = event.source.parent.getComponent(‘Table’)  
data = event.source.parent.getComponent(‘Table’).data  
RecordID = str(event.source.parent.RecordID)  
LabTimeOut = str(event.source.parent.getComponent(‘TimeL’).text)  
Remarks = str(data.getValueAt(selectedRow, “LabComment”))  
system.db.runUpdateQuery(“UPDATE OT\_Trolley\_Allocation SET Status = ‘Passed’, LabComment = '”+ Remarks +"’ WHERE WO\_Num IN (" + WO\_Num + “)”)  
system.db.runUpdateQuery(“UPDATE OT\_Allocation\_Status\_History SET LabOut = '”+LabTimeOut+"’, LabResult = ‘Passed’, LabRemarks = ‘"+ Remarks +"’ WHERE WO\_Num IN (" + WO\_Num + “) and RecordID = '”+ RecordID +"’")[/code]

The WHERE IN clause allows you to use a list of values.

---

<div class="post-metadata">

**Author:** ![trishhiyah](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@trishhiyah](https://forum.inductiveautomation.com/u/trishhiyah)\
**Post date:** [October 30, 2015, 1:53am UTC](https://forum.inductiveautomation.com/t/multiple-selection-in-table-then-input-same-result/10684/7 "2015-10-30T01:53:31Z")

</div>

Thank you so much for that. I appreciate the help.  
but I got an error like this. ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f0984456f8dd47c5beb0a68b72c3d6cf62ef2aa.jpeg)  
at line 15 [code]import sys

selectedRow = event.source.parent.getComponent(‘Table’).selectedRow  
selectedRows = event.source.parent.getComponent(‘Table’).getSelectedRows()  
table = event.source.parent.getComponent(‘Table’)  
data = event.source.parent.getComponent(‘Table’).data  
RecordID = str(event.source.parent.RecordID)  
LabTimeOut = str(event.source.parent.getComponent(‘TimeL’).text)  
Remarks = str(data.getValueAt(selectedRow, “LabComment”))  
WO\_List =   
for row in selectedRows:  
WO\_List.append(str(data.getValueAt(row, “WO\_Num”)))

#line 15  
WO\_Num = str(WO\_List -1, 1)  
system.db.runUpdateQuery(“UPDATE OT\_Trolley\_Allocation SET Status = ‘Passed’, LabComment = '” + Remarks + “’ WHERE WO\_Num IN '” + WO\_Num + “’”)  
system.db.runUpdateQuery(“UPDATE OT\_Allocation\_Status\_History SET LabOut = '” + LabTimeOut + “’, LabResult = ‘Passed’, LabRemarks = '” + Remarks + “’ WHERE WO\_Num IN’” + WO\_Num + “’ and RecordID = '”+ RecordID +"’")[/code]

when I add a bracket in line 15 code

```auto
WO_Num = str(WO_List [-1, 1])
```

got an error  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f0984456f8dd47c5beb0a68b72c3d6cf62ef2aa.jpeg)
