Jquery Datatable服务器端处理ajax调用的成功回调
我想在中指定的URL的服务器端调用完成后隐藏一些列Jquery Datatable服务器端处理ajax调用的成功回调,jquery,ajax,datatables,jquery-datatables,Jquery,Ajax,Datatables,Jquery Datatables,我想在中指定的URL的服务器端调用完成后隐藏一些列 sAjaxSource:url 在我使用fnCreatedRow创建完行之后。我想执行列可见性语句 table.fnSetColumnVis(0,false,false) 用于此回调中的多个列。在datatable中有这样做的方法吗?我尝试过使用fnDrawCallback和fnRowCallback但它们根本不执行 我写的代码如下 table = $('#ID').dataTable({ "bServerSide": true,
sAjaxSource:url
在我使用fnCreatedRow
创建完行之后。我想执行列可见性语句
table.fnSetColumnVis(0,false,false)代码>
用于此回调中的多个列。在datatable中有这样做的方法吗?我尝试过使用fnDrawCallback
和fnRowCallback
但它们根本不执行
我写的代码如下
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
});
table=$('#ID').dataTable({
“bServerSide”:正确,
“bProcessing”:正确,
“自动宽度”:正确,
//“bInfo”:假,
“dom”:“Clfrtip”,
“滚动”:“350px”,
“卷轴折叠”:错误,
“分页”:正确,
“scrollX”:正确,
“毁灭”:真的,
“sAjaxSource”:url,
“aoColumns”:[
{
“目标”:0,
//“可见”:是的,
“标题”:“选择客户端”,
“可搜索”:错误,
“可移植”:错误,
“宽度”:“10%”
},//许多这样的条目
],
“fnCreatedRow”:函数(nRow、aaData、iDataIndex){
//功能体
},
“drawCallBack”://我希望在fnCreatedRow结束后执行的实际代码
});
试试这个:
"drawCallback": function(settings) {
//do whatever
}
我有一个类似的案例,我通过将xhr事件附加到我的数据表来解决它
见:
在我的例子中,$table是我在初始化我的datatable时预先声明的变量。在获取数据后或在绘制表格后是否需要回调?在绘制表格后是否尝试过不使用fn
?只是drawCallback
?在你的代码中哪里有这个?如果不在正确的位置,它将无法工作。请小心,您提供的链接适用于1.10版及以上版本。但问题中的参数名称表明nnm使用的是dataTables的旧版本,早于1.10。
$table.on('xhr.dt',
function (e, settings, data, xhr) {
//do something with the 'data' returned from server
//OR handle some error using the 'xhr' request
});