我在我的网页中使用DataTables,它从服务器Server-side processing加载内容,我想向其添加rowReordering jquery-datatables-row-reordering功能。这是我以前的尝试。DataTables行在serverSide处理完成后重新排序
$('.data_table').dataTable({
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "Display <select>'+'<option value=\"10\">10</option>'+'<option value=\"20\">20</option>'+'<option value=\"30\">30</option>'+'<option value=\"40\">40</option>'+'<option value=\"50\">50</option>'+'<option value=\"-1\">All</option>'+'</select> records"
},
"processing": true,
"serverSide": true,
"ajax": dataUrl
}).rowReordering({
sURL:sortUrl, // Let the server page know if order is changed
sRequestType: "GET",
fnAlert: function(message) {
modalError("Server Error",message,null); // Error message if an server error occured during the process
}
});
$.extend($.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
});
这实际上使阻力和数据的下降,但这样做后不发送任何通知的服务器,也不是被丢弃的行会留在它被丢弃(这又回到了它原来所在之处)。
我也尝试了以下操作。
$table = $('.data_table').dataTable({
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "Display <select>'+'<option value=\"10\">10</option>'+'<option value=\"20\">20</option>'+'<option value=\"30\">30</option>'+'<option value=\"40\">40</option>'+'<option value=\"50\">50</option>'+'<option value=\"-1\">All</option>'+'</select> records"
},
"processing": true,
"serverSide": true,
"ajax": dataUrl,
"fnInitComplete": function(oSettings, json) {
$table.rowReordering({
sURL:sortUrl, // Let the server page know if order is changed
sRequestType: "GET",
fnAlert: function(message) {
modalError("Server Error",message,null); // Error message if an server error occurred during the process
}
});
}
});
$.extend($.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
});
在此,我打电话rowRedordering
内fnInitComplete
回调。但是这给出了与之前相同的结果。就像在拖放中一样,但它不会发送服务器通知(并且该行不会保留在放置的位置,它可以返回到之前的位置)。
在我添加了服务器端处理的数据以初始化表之前,重新排序工作完美。那么,我在这里做错了什么?
哇,伟大找到CSRF攻击 – Craig 2016-07-07 21:57:46
什么? – NineCattoRules 2017-10-17 17:41:56