Similar to how len() works but instead of giving the total number of rows, is there like a “count” equivalent in ignition? I want to be able to count the selected rows in either a table, a tree view or a list.
I have a tree view that allows users to select multiple rows and was hoping I could count how many rows they have selected.
Thank you for your help.
zacht
May 10, 2021, 7:04pm
2
You can get the number of rows in a dataset named data using data.rowCount
or data.getRowCount()
.
I don’t know if one is better than the other.
Tested with the dataset behind a Power Table in Vision.
pt = event.source.parent.getComponent('Power Table')
data = pt.data
print data.getRowCount()
is there a getRowCount() for tree view? I’m currently using a tree view component.
lrose
May 10, 2021, 7:22pm
4
The table has a getSelectedRowCount()
https://docs.inductiveautomation.com/display/DOC81/Vision+-+Table
The Tree View has a getSelectedItems()
or getSelectedPaths()
which you can then use the len()
function on.
itemCount = len(event.source.getSelectedItems())
https://docs.inductiveautomation.com/display/DOC81/Vision+-+Tree+View
The List has a getSelectedValues()
which you can then use the len()
function on.
valueCount = len(event.source.getSelectedValues())
https://docs.inductiveautomation.com/display/DOC81/Vision+-+List
Of course if you want to loop through those you don’t need the count
for item in event.source.getSelectedItems():
print item
2 Likes
awesome, this works. thank you!