plotly / dash-table

OBSOLETE: now part of https://github.com/plotly/dash
https://dash.plotly.com
MIT License
419 stars 74 forks source link

Strategy for data / selected_rows / selected_row_ids #479

Open alexcjohnson opened 5 years ago

alexcjohnson commented 5 years ago

While investigating a community post about expandable rows I suggested a callback changing data based on selected rows - unfortunately this has problems: if you just use selected_rows, then selecting an earlier row will mean the index of a later selected row changes. We could, I suppose, work around this if we had a selected_rows_timestamp or something, and output both data and selected_rows.

The more obvious way to work around it would be to use selected_row_ids. However, selected_rows and selected_row_ids don't update correctly when we change data - related to https://github.com/plotly/dash-table/issues/239 but it's tougher here as there isn't necessarily any link between prior and new rows. We could make such a link if the user has provided row IDs - in which case it would make sense to use selected_row_ids as the source of truth and update selected_rows to match.

Related: currently selected_row_ids is read-only; writing to it doesn't error but doesn't update the displayed table either. Would be nice if it could at least optionally be writable. Similarly for active_cell and related props, row and column must be used to write these props, row_id and column_id are ignored (and you get an ugly error "Cannot read property 'NaN' of undefined" if you don't provide row and column)

hiwaveSupport commented 4 years ago

Had same issue as we are refreshing the datatable based on user selecting another value from a dropdown. We just return the selected_rows = [] as part of the datatable callback that refreshes the table, which is working as expected. Please do let us know if there is a more elegant way to reset the selected rows on datatable refresh.

luhart commented 4 years ago

Expandable rows would be super useful. Do you see any viable paths for implementing this?