Forum Archive

Hightlight a row from table view.

ryanvolap

Hi all.
I'm new in pythonista.
I have a question: Is it possible to highlight specific row of a tableview from user input. For instance, I get a tuple (0,2) from a user (section 0, row 2) and it will highlight row 2 of the table automatically (like changing a cell background color).
Thanks.

Phuket2

@ryanvolap , are you talking about TableView.selected_row method? This can select the row programmatically

JonB

The other approach would be to have your datasource provide a tableviewcell with a highlight applied based on the list of cells to highlight -- you would have to reload to update.

Another option is to create your tableviewcell's once, and store these in your datasource. tableview_cell_for_row would need to return the stored cell. But then you have access to the cell, so can change its contents in realtime. This is not recommended if you have a very large table, since you are wasting memory on cells that are off screen.