Update problem when using stateSave with serverSide
Update problem when using stateSave with serverSide
Dear Allan,
I have a datatable with a createdRow function which calls $("td:eq(1)", row).append(...)
It works perfectly with stateSave: true, OR with serverSide: true
However, when using stateSave AND serverSide at the same time, it works on very first webpage call (because cache is empty, so stateSave does not affect loading) and if I refresh the webpage, my custom HTML is no more visible. I need to change sorting, or change page, and come back to the first page to see my custom HTML. If I press F5, same problem occurs again and again.
Same behavior on Firefox and Chrome.
PS: I have tried to add something like table.rows( row ).invalidate().draw(); but it does solve anything, and prevents other pages to display the HTML: I suppose because this should not be called inside createdRow.
Do you have a solution?
Answers
I tried what you described here:
http://live.datatables.net/muluyupu/1/edit
It seems to work. Maybe I misunderstood the problem. Please either update my example or provide a link to a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
You don't want to use
table.rows( row ).invalidate().draw();
withincreated Row
.Kevin
Dear Kevin,
Thanks for your answer. I have tried many things, until I only had one candidate.
The problems comes from colReorder js plugin 1.4.1
If I use last 1.5.1, there is no more problem.
Here is the fiddle with the 1.4.1 coreorder activated, you have exactly the problem I mentioned : http://live.datatables.net/rikohiqu/2/edit
Sorry to have bothered with an old bug. Was this problem referenced? Where are the release notes with bug fixes for the plugins like this one?
Hi @gboussin ,
Thank you for the test case - I've tried it, but it seems to be behaving as expected to me. Can you provide steps on how to reproduce your issue, and give details on what you would expect the behaviour to be instead.
Cheers,
Colin
The line added wasn't saved, sorry.
I have added
which gives
http://live.datatables.net/zugumayo/1/edit
You launch it once, it works. Twice, it doesn't give you the HTML, but changing pages does
Hi @gboussin ,
Hate to say it, but tried it again, and the table is always present for me. It would be worth running
state.clear()
on your browser, or try in private mode, and see if it still occurs - there might be some history that's interfering with your code.Cheers,
Colin
I see the problem. I've tried in both Chrome and Safari. Also tried Chrome in private mode. I open the link and click
Run with JS
and the column withTest
is now blank. I added a console.log to make surecreatedRow
runs and it does. Comment outcolReorder: true,
and clickRun with JS
multiple times and the column always hasTest
. UncommentcreatedRow
and clickRun with JS
twice and theTest
column is now blank.As @gboussin mentioned it seems the combo of
colReorder
andstateSave
is the issue.Kevin
Ah, thanks Kevin, those steps help - I can see it. Sorry about the delay, this thread got lost in the inbox.
C
Hi,
Release notes are available on the CDN.
The change that is causing the different behaviour in 1.5.x is this commit, which is noted in the 1.5.0 release notes:
Its far from apparent that this change would cause the behaviour you are seeing though! What is happening when an invalidation is run is DataTables will effectively rebuild the row. So the change you made by DOM insertion will be wiped. You'll still have that behaviour with 1.5.1 when you do actually reorder the columns.
The answer is not to use
createdRow
to insert content. Instead usecolumns.render
.Allan