Update problem when using stateSave with serverSide

Update problem when using stateSave with serverSide

gboussingboussin Posts: 13Questions: 4Answers: 0

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

  • kthorngrenkthorngren Posts: 5,317Questions: 19Answers: 1,189

    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(); within created Row.

    Kevin

  • gboussingboussin Posts: 13Questions: 4Answers: 0

    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?

  • colincolin Posts: 4,309Questions: 0Answers: 767

    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

  • gboussingboussin Posts: 13Questions: 4Answers: 0

    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

  • colincolin Posts: 4,309Questions: 0Answers: 767

    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

  • kthorngrenkthorngren Posts: 5,317Questions: 19Answers: 1,189

    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 with Test is now blank. I added a console.log to make sure createdRow runs and it does. Comment out colReorder: true, and click Run with JS multiple times and the column always has Test. Uncomment createdRow and click Run with JS twice and the Test column is now blank.

    As @gboussin mentioned it seems the combo of colReorder and stateSave is the issue.

    Kevin

  • colincolin Posts: 4,309Questions: 0Answers: 767

    Ah, thanks Kevin, those steps help - I can see it. Sorry about the delay, this thread got lost in the inbox.

    C

  • allanallan Posts: 49,303Questions: 1Answers: 7,235 Site admin

    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:

    Fix: Don't invalidate row data if no changes were made on column reordering

    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 use columns.render.

    Allan

Sign In or Register to comment.