DataTable selected_rows

Hi there,

I have a datatable with pagination and a callback which should update the selected rows for every page.
I don’t see why but when I change the page, the rows are selected for a sec and then deselected automatically. Did you encounter anything similar?

The callback:

@app.callback(
[Output(‘tbl2’, ‘data’),
Output(‘tbl2’, ‘selected_rows’)],
[Input(‘tbl2’, “page_current”),
Input(‘tbl2’, “page_size”)])
def update_table(page_current,page_size):
data = dframe.iloc[page_current*page_size:(page_current + 1)*page_size].to_dict(‘records’)

return data, [0,1,2,3,4]

Thanks a lot!

hi @Listvan
can you show a short gif of what’s happening?

Hi,

Yep:
Hnet.com-image

Thank you!

@Listvan
I’m not sure what’s happening to your DataTable, but according to your code, you are always returning the same selected rows [0,1,2,34].
What exactly are trying to achieve? Are you trying to select the first 5 rows of every page?

This DataTable tutorial that I created with explanations on pagination and selected_rows might be helpful…