我遇到的问题是,行重新排序在排序任何列后停止工作。该行返回到选择放置的位置。 在此先感谢
答案 0 :(得分:0)
使用dataTable 1.10.x和" native" RowReorder插件。将以下文件添加到您的项目中:
<script src="https://cdn.datatables.net/rowreorder/1.0.0/js/dataTables.rowReorder.min.js"></script>
<link href="https://cdn.datatables.net/rowreorder/1.0.0/css/rowReorder.dataTables.min.css" type="text/css" rel="stylesheet">
$('#table').DataTable({
rowReorder: true
});
Check demo : https://jsfiddle.net/u7mdqwot/
答案 1 :(得分:0)
解决了这个问题。 似乎排序和行重新排序并不起作用。
gtblAssignedTasks = $("#tblAssignedTasks").DataTable({
"language": {
"oPaginate": {
"sFirst": "<<",
"sPrevious": "<",
"sNext": ">" ,
"sLast": ">>"
},
"emptyTable":"No record found"
},
"dom": '<"top"iflp<"clear">>rt',
'iDisplayLength': 50,
"bLengthChange": true,
"responsive": false,
"bFilter": true,
'rowReorder': {
dataSrc: 'Priority'
},
columnDefs: [
{ targets:0, visible: false }
] ,
"bSort": true,
"bauto":false,
"bPaginate": true,
"Paging": true,
"bInfo":false,
//Commented,as Pager and filter isnt required
"sDom": '<"row tblAssignedTasks" <"col-lg-3 col-md-3 col-sm-3 col-xs-12 pull-right filter"Rr> ><"" t><"row zeromargin clsFooter" <"span9"p> >',
"pagingType": "full_numbers",
"sServerMethod": "POST",
"sAjaxSource": "@Url.Action("GetToDoListTasks", "Test")",
"aoColumns":tblAssignedTasksColumns,
"createdRow": function ( row, data, index )
{
},
"initComplete": function()
{
}
});//datatable end
通过设置&#34; bSort&#34;:false甚至没有工作。 所以我的解决方法是在数据表初始化中设置&#34; bSort&#34;:true并在列定义中将单个列的排序设置为false,如下所示
var tblAssignedTasksColumns= [
{ "sTitle": "Priority", "mData": "Priority" , "sClass": "reorder", "sDefaultContent": "" } ,
{ "sTitle": "Priority", "mData": "Priority1" ,"sClass": "reorder" , 'bSortable': false, "mRender": function (data, type, row)
{
return GetPriorityRandom(row) ;}, "sDefaultContent": "1" },
{ "sTitle": "Description", "mData": "KindOfAlert", 'bSortable': false, "sClass": "tblDest ", "sDefaultContent": "","mRender": function (data, type, row){
return GeneratePriorityLabel(row )
}
}
, { "sTitle": "Status", "mData": "Status", 'bSortable': false, "sClass": "clstblInvoiceAdjustment tdAssignedTasksStatus", "mRender": function (data, type, row)
{ return GetStatus(row) }, "sDefaultContent": "" }
];