Issue: Perspective table row remains highlighted after selectedRow property is set to None. Goal: Using script, deselect and un-highlight the row of a table component.
More info: I am attempting to deselect the row of the table component. I have successfully deselected the row using ...props.selection.selectedRow = None. Yet the row remains highlighted. Any suggestions to un-highlight the row would be greatly appreciated.
Note: The table that I am working with has two columns, but only one is shown.
I was able to find a work around. If the selectedRow and selectedColumn are set to -1, the row is unhighlighted. Then the selectedRow and selectedColumn can be set to None.
The most reliable way I've found to do this is to disable row selection, let that bounce over to the browser, which will then clear props.selection.data. A change event on props.selection.data can then re-enable row selection when it sees the new empty value.
In general, properties that are set via user interaction in the browser, like selections, need to also be unset by the browser. Unsetting them directly via script (which runs in the gateway, not the browser) is unreliable.
I've been using a library function I created for this purpose. I could be mistaken but I think @pturmel has indicated that Timers aren't totally reliable, but they've always seemed to work well for my purposes.
No need for a timer if you follow my pseudocode. And a timer doesn't ensure that the traffic made the round trip to the browser. (Do note that you should not blindly disable row selection--only do so when there is a non-empty selection that you wish to eliminate.)
I'm trying to do this deselect a row thing.
Are you putting this on a row-click event or on a 'clear selection' button?
If it's on the row-click (which I'd prefer, so that's what I'm attempting), what are you using as parameters to trigger disabling row selection such that it only happens if the row is currently highlighted?
Button with script onActionPerformed: self.[relPathToTable].props.selection.enableRowSelection = False
Button.enabled has expression binding !isNull({[relPathToTable].props.selection.selectedRow})
Table.selection.selectedRow has a change script. if currentValue.value is None: self.props.selection.enableRowSelection = True
Button disables row selection. This nulls table.data.selectedRow. Upon that, change script re-enables table.selection.enableRowSelection so rows can be selected again.
Wonky in how it works, but clean user experience. Thanks to @pturmel for this tip.