Wrong row ID being returned in 'select' event
Wrong row ID being returned in 'select' event
As a consequence of this, I am saving values of a datepicker field in session storage using the row id as key. When the page is returned to, rowcallback checks there's a value for the key in the sessionstorage and if there is, calls select() to ensure it appears selected.
This is failing. For some reason, if go and select something with DT_RowId = 'row_2500'. This works fine, until i navigate away and come back to the page. Now depending on the position of the selected row on the newly displayed page (say its the first, this is given value of 1,) it tries to retrieve sessionstorage for key 'row_1' within the 'select' event (using dt.row( indexes ).id()). This of course does not exist soo I'm unable to achieve the desired effect of displaying what's previously selected correctly. Every item I select suffers same fate of being retrieved with a cardinal number relative to position in the page whilst all other rows still have their original ids.
I've been on this for a couple of frustrating days. Is there an easier solution?
Please note: I've used console.log to display row.data() within rowcallback as well as the select event: for the above example these show 'row_2500' and 'row_1' respectively for the very same row.
This question has an accepted answers - jump to answer
Answers
My suggestion is to build a test case showing what you are doing so we can help you debug:
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Ok, I'm trying to do this but even console.log doesnt seem to do anything. Please look at http://live.datatables.net/rilubagi/1/edit
I added the Select extension JS and CSS and enabled Select on the Datatable. I provided a small data set, including DT_RowId, that is applied to the table. Now the start of your example works:
http://live.datatables.net/rilubagi/1/edit
I'll let you continue with you session storage, etc.
Kevin
Please can you take a look at it and redo? Perhaps I overwrote from my side whilst trying to get it to work
Sorry wrong link:
http://live.datatables.net/ruvejobo/1/edit
Kevin
Thank you: whilst trying to recreate this I seem to have stumbled on the errant code. Let's keep fingers crossed.