Forum Archive

Resetting ListDataSource selection

cook

Does anyone know how to reset the ListDataSource selection?

By default it is -1 ... no selection.

When we do an action, you can get the row number. Example:

ListDataSource.action = dostuff

def dostuff(sender):
    sender.selected_row

But if I just do ListDataSource.selected_row = -1 it does nothing.

I can do a ListDataSource.reload() but that's not ideal because it could take precious processing power to reload my list. (for now this is what I've done)

JonB

The tableview selected_row controls the displayed selected row.
When the user taps, the tv calls tableview_did_select on the delegate, which is where it sets the ListDataSource selected row so the action can see it.

So... if you just want to set the selected row, do it on the tableview.
If you want the action called, you need to call the delegate yourself

tv.selected_row=(0,row)
tv.tableview_did_select(tv,0,row)
cook

@jonb many thanks, that got it!