Calling .draw() but not cause a new server request?

Calling .draw() but not cause a new server request?

sapotsapot Posts: 14Questions: 8Answers: 0

I basically have a serverSide datatable that is loaded hidden at start but when the table is visible I was using the 'trick' on the adjust page: https://datatables.net/reference/api/columns.adjust()

table.columns.adjust().draw();

The problem I have now since upgrading to 1.12.1 is that the server is called twice when this table initializes (one normal call and another provoked by draw()). Before 1.10.25 there was actually a bug preventing this ajax call duplication.

But to put it simply: is there any way to call draw() but force it to not trigger a new ajax request? I really just want the columns to resize and to have that visible.

Answers

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Do you really need the draw() in that chain? Could you just use table.columns.adjust()?

    Allan

  • sapotsapot Posts: 14Questions: 8Answers: 0

    My understanding is that we need to call draw to 'see' the changes made by table.columns.adjust() ? at least the reference page I linked clearly shows in the example to call the .draw().

    Any chance we can get an option on .draw() to trigger serverSide update or not?

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    No - a draw() call will aways hit the server-side when serverSide is enabled I'm afraid.

    My understanding is that we need to call draw to 'see' the changes made by table.columns.adjust()

    Don't think so. the column sizes will still be adjusted.

    at least the reference page I linked clearly shows in the example to call the .draw().

    That's me trying to cover all bases! Some plug-ins use events on draw and not columns adjust.

    It might be worth trying it without the draw() call if you haven't already.

    Allan

Sign In or Register to comment.