我在我的網頁中使用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