Selecting multiple vision table rows from python?

I’m not able to select multiple rows in a vision table using python. The selection mode in the table is set to “multiple interval”, however the following code always selects a single line (the last), instead of lines 0, 2, 4 etc.:

for row in range(0, mytable.data.getRowCount(), 2):
  mytable.setRowSelectionInterval(row, row)

As far as I can tell there’s no setSelectedRows() function or similar. Am I missing something?

Use:

table = event.source.parent.getComponent('Power Table 1').getTable()

table.getSelectionModel().addSelectionInterval(0, 0)
table.getSelectionModel().addSelectionInterval(2, 2)
table.getSelectionModel().addSelectionInterval(4, 6)

So a power table is needed? May then I ask for a setSelectedRows(list_of_rows_to_select) to be added to the table component as a feature request? Thanks

No, basic table works too. Just create your own function.

def setSelectedRows(table, rows):
	for row in rows:
		table.getSelectionModel().addSelectionInterval(row,row)
		
table = event.source.parent.getComponent('Table').getTable()
setSelectedRows(table, [0,2,4,5,6])
4 Likes

Hi,
Is there a way to do the same in Perspective? I'd like to select all the rows in the table.
Thanks.

You've asked this all over the forum. The same people who've seen your other questions are the ones who see this question. (This forum really isn't that large.)

Vision is so fundamentally different from Perspective that nearly nothing transfers in regards to component behavior. Perspective has different components from Vision. Totally different code under the hood for all of them. You are going to have to wait until IA implements the behavior you want, or create your own table component with the SDK.