Can we retrieve the selected row indexes of a perspective table with selection mode "multiple interval" ?
It looks like props.selection.selectedRow
just supplies the row number of the last-clicked item.
If there is a unique column in the table you could script a search for the values returned in props.selection.data
and return the selected row numbers.
What is the real problem you are trying to solve?
Yes, vision table has a convenient .getSelectedRows().
Nothing for perspective Table...
I need to remove multiple line in a table with data binded to a dataset.
To update the dataset, selected row indexes would have been the more simple method...
It might not. There wouldn't be a correspondence between the table row numbers and the database row numbers.
You can retrieve the record IDs and not display them in the table. That way you can retrieve a list of record IDs from props.selection.data
for your SQL delete.
I have the same ask. I have table selection mode set to multiple interval and these are the row/cols I want to update when a value is received, but the table selection properties give no indication of which rows have been selected.
@mazeyrat Did you find a solution to this?
As suggested previously,
- Add a row ID column to the table's datasource but don't display it.
- Loop through
selection.data
and update the relevant datasource rows by datasource ID. - Refresh the binding (if required).
Yes that is the solution
I have an id column configured and not displayed, but the selection data only returns the value of the selected row/col when mode is set to multiple interval.
Possibly a bug? I noticed that when scripting to change the selected column, sometimes the selection data returns the whole rows data instead of just the selected columns value.
Try
selection.enableColumnSelection : false
That way you should get whole rows.
Except that I need the user to select individual columns. They select a column and then add a check value. They can select multiple columns and that value is applied to all selected cells. They select multiple row cells and the value is applied to those as well.
I'll put a ticket in with IA but I appreciate your help. thx.
You could try keeping track of them yourself. I've just tried it and had mixed success.
- Create a custom property on the table. I called mine
selectedCells
and made it an array. - Create a binding on the
custom.selectedCells
.
Script
def transform(self, value, quality, timestamp):
selectedCells = self.custom.selectedCells
selectedCells.append([value.row, value.column])
return selectedCells
Problems:
- I'm getting some double events resulting in duplicates in the table.
- You'll need a reset button to clear the selection.
I tried playing around with table events and the onSelectionChanged
event looked promising but I discovered that (in Designer at least) that it fires before props.selection.selectedRow
and props.selection.selectedColumn
get updated.
That's an idea. There's always a way, I'll put that in place, but have submitted a ticket, ideally it'll be part of the standard table functionality along with freeze columns/rows and draggable rows