Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Success callback for Datatable server side processing ajax call

I want to hide some columns after my server side call completes for the URL specified in

sAjaxSource: url,

and after I am done creating rows using fnCreatedRow. I Want to execute column visibility statements

table.fnSetColumnVis(0, false, false);

for multiple columns in this callback. Is there a way to do this in datatable? I have tried using fnDrawCallback and fnRowCallback but they do not execute at all.

The code I have written is as follows.

table = $('#ID').dataTable({
    "bServerSide": true,
    "bProcessing": true,
    "autowidth": true,
    //"bInfo": false,
    "dom": 'C<"clear">lfrtip',

    "scrollY": "350px",
    "scrollCollapse": false,
    "paging": true,
    "scrollX": true,
    "destroy":true,
    "sAjaxSource": url,
    "aoColumns": [
     {
           "targets": 0,
           //"bVisible": true,
           "title": "Select Client",
           "bSearchable": false,
           "bSortable": false,
           "width": "10%"
       },//Many such entries
    ],
    "fnCreatedRow": function (nRow, aaData, iDataIndex) {
     //Function body
    },
    "drawCallBack" : //Actual code that i want to get executed after fnCreatedRow has ended
});
like image 403
nnm Avatar asked Dec 11 '22 00:12

nnm


1 Answers

Try this:

"drawCallback": function(settings) {
               //do whatever
            }

https://datatables.net/reference/option/drawCallback

like image 199
jonmrich Avatar answered Dec 13 '22 14:12

jonmrich