Datatable reDraw issue on ajax call.

Datatable reDraw issue on ajax call.

sandybsandyb Posts: 2Questions: 1Answers: 0
edited March 2016 in Free community support

Hi,
i am using datatable with php and mysql in such a way that it hits Ajax call for the first time in which it loads all the data only one time and process to client side .

var otable = $('#datatable_fixed_column').DataTable(
    {
"bProcessing"    : false,
serverSide"         : false,
\\here code contains datatable columns and bla..bla..bla...
"order"             : [[ 2, 'DESC' ]],
        "autoWidth"         : true,
    });

In short i have set bProcessing, serverSide = false which reduce my Ajax call while i paginate from 1 page to 2 (another) .
now this process works for first time or while paginate ,
But now i wanted to change my datable result based on another ajax call i.e (suppose i have calendar control in which i selects date and sends ajax call to server and redraw the table ). I wanted to redraw table second time also based on date selection .
for that i have written belows code.

             var otable     = $('#datatable_fixed_column').DataTable();
            otable.draw();

which works if i set true to bProcessing AND serverSide .
but if i set it to false then it wont works or nither sends ajax call also . so i changed it to

otable.fnDraw();

then it give me belows error

TypeError: otable.fnDraw is not a function

can any one tell me how do i redraw my datable when serverside and processing is false apart from my first ajax call .

Please replay ,
Thaks in Advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,230Questions: 1Answers: 10,417 Site admin
    Answer ✓

    TypeError: otable.fnDraw is not a function

    Top FAQ :-). The draw() method is the correct one to use rather than the legacy fnDraw method (use $().DataTable() to access the new API).

    If you want to reload the table from the Ajax source and you are using client-side processing, then use ajax.reload().

    Allan

  • sandybsandyb Posts: 2Questions: 1Answers: 0
    edited March 2016

    Cool, i already got answer but thanks its great..
    it works for me

This discussion has been closed.