Scroller is not working if we reinitialize the datatable

Scroller is not working if we reinitialize the datatable

joyaljoyal Posts: 2Questions: 1Answers: 0

I am using scroller plugin of datatable with server-side data processing. Due to some reason, scroller is not working if we call datatable again after some operation in clientside.

$("#expenseTable").DataTable({serverSide: true,scrollCollapse: true,scrollY: 300,scrollX: true,scroller: {loadingIndicator: true,displayBuffer: 20},$.ajax({......})});

Steps to reproduce:
Step 1: load a page with a datable which contain scroller
Step 2: call again that datatable using $("#expenseTable").DataTable({..........});
Step 3: scroll down to the page. It won't call ajax for fetching data.

Summary: scroller won't work if we call $("#expenseTable").DataTable({..........}) twice.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @joyal ,

    Are you seeing a console error reporting that you can't reinitialise the table?

    We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • joyaljoyal Posts: 2Questions: 1Answers: 0

    Hi Colin,

    Found the issue. It is due to the length of datatable adjusting in ajax block of datatable manually like data["length"]=40 while reinitializing.

    Thanks for your reply. I found this issue while adding the code in jsfiddle as part of your form rule

    Regards,
    Joyal

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @joyal ,

    Excellent - that's it, often when you simplify the problem down into a fiddle the cause becomes apparent! :)

    Cheers,

    Colin

This discussion has been closed.