Disable/enable row selection in table

Hello, I've got a button with this action:

def runAction(self, event):
    self.view.custom.enable_selection = False
    import time
    time.sleep(0.1)
    self.view.custom.enable_selection = True

With the sleep, it works. But without it, enableRowSelection doesn't change to false then true, it just stays in true.

Not entirely sure what you are looking to accomplish here, but you are most likely just not “seeing” then change without the sleep.

That would be pretty much instantaneous without the sleep.

To test you can just do it like this and then watch the console as you click it.

self.view.custom.enable_selection = False
system.perspective.print(‘Disabled’) 
self.view.custom.enable_selection = True
system.perspective.print(‘Enabled’) 

Yeah I mean that's the issue here. I want to give the user the ability to unselect all the rows by clicking a button, which can be done changing the enableRowSelection property to False. But, as the user still needs to select new rows after unselecting all the rows, I have to set the property back to True. I've tried using a change script but the same happens if I don't use time.sleep.

Not sure about 8.3, but in 8.1 setting both selectedColumn and selectedRow to None would unselect all the rows.

your_table_component.props.selection.selectedRow = None
your_table_component.props.selection.selectedColumn = None

(Edit: format correction)

3 Likes

Oh wow well this is embarrassing, I was overcomplicating it. Thanks a lot!