数据服务器端处理ajax调用的成功回调

nnm*_*nnm 3 ajax jquery datatables jquery-datatables

我希望在服务器端调用完成后为指定的URL隐藏一些列

sAjaxSource: url,

在我完成使用的行创建行之后fnCreatedRow.我想执行列可见性语句

table.fnSetColumnVis(0, false, false);

对于此回调中的多个列.有没有办法在datatable中执行此操作?我已经尝试使用fnDrawCallbackfnRowCallback,但他们根本不执行.

我写的代码如下.

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
});
Run Code Online (Sandbox Code Playgroud)

jon*_*ich 9

试试这个:

"drawCallback": function(settings) {
               //do whatever
            }
Run Code Online (Sandbox Code Playgroud)

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

  • 请注意,您提供的链接适用于1.10及更高版本.但是问题中的参数名称表明nnm正在使用遗留版本的dataTables,在1.10之前. (2认同)