Is it possible to get a continous ‘row number’ shown in the first column of a Dash DataTable?
These numbers shall not be part of my data frame, but shall be generate by Dash DataTable, so that I will always geht row numbers starting with 1,2,3, … independent of the sorting or filtering I do using by DataTable in the front-end.
Thanks for help, Andreas.
Some further information with a picture, since I did not get any response or help yet.
In the screenshot you see my solution an the problem.
I use ‘datatable’ to list information, and a added a ‘running index number’ (#) in my source data, to get “some numbering” shown with the data.
But if I filter now in the datatable (e.g. for ‘scalane’), the numbering obviously now does not start with ‘1’ as I would like to have it. Such a re-numbering feature would need to be supported by ‘datatable’.
I hope there is such a feature built into ‘datatable’, but I just do not know how to configure it. Thanks for help.
I believe the number comes from the rowId which is preserved after sorting and filtering and I am not aware that this can be set just by passing a simple parameter.
A certainly overkill approach would be to implement filtering (and paging/sorting) yourself via a callback (see for instance here), then you are allowed to return the data Output as you want, including adding a column with fixed row numbers.
Just mentioning in case you desperately needed it done and no other solution pops up…
Thanks for quick response, junior.
Indeed, developing my own paging and filtering is what I just wanted to avoid.
I was believing that this numbering shoud have been a feature in ‘datatable’, since it would be so easy to implement - but if it is not yet available, I might suggest this as a feature update to plotly/dash in the future.