Extra column data function calls when using ajax.reload

Extra column data function calls when using ajax.reload

anne_banne_b Posts: 2Questions: 1Answers: 0

If using server side mode, and your columns's data is specified with a function, I've found that when you call ajax.reload() on your table, it calls that data function on the old data before calling it on your new data.

Here is a jsfiddle example https://jsfiddle.net/anneb574/1o6mtwxc/23/
I have made it so that whenever the data function is called, it logs the id of the row, so you can see what it's being called on.

If you go to the second page of data, and click the reset button, you'll see that the function is called on the page 2 data twice before being called on the page 1 data.

This seems fairly harmless, albeit inefficient, but my setup is a bit more complex and it's causing issues for me. (basically, I have a complex data layer providing data to the table, which my column's data fn needs to access, but with extra calls to data that no longer exists, I have to add more logic to prevent errors)

This question has an accepted answers - jump to answer


  • colincolin Posts: 7,697Questions: 0Answers: 1,297

    Yep, ajax.reload() is expected to be called when using plain Ajax, not when using serverSide. If you want to get new data when serverSide is enabled, you would just redraw the table/page with draw().


  • anne_banne_b Posts: 2Questions: 1Answers: 0

    @colin thank you for your reply! You may be right about that, I didn't know and the method documentation doesn't mention it's not for use with serverSide. Draw does work as well.

    However, it still has extra redraws with old data, even when switching to the draw() method.

    Do you know how I can avoid these?

  • allanallan Posts: 51,272Questions: 1Answers: 7,724 Site admin
    Answer ✓

    ajax.reload() will actually work with server-side processing which is why the documentation doesn't mention SSP specifically for it. Its just a little redundant since you can simply call draw().

    I agree that there appears to be something odd going on here. I'll look into it a bit more and post back as soon as I can.


Sign In or Register to comment.