jQuery DataTables rowReorder issue

前端 未结 4 508
终归单人心
终归单人心 2021-01-03 05:05

I am using DataTables along with the rowReorder plugin against a static table (non AJAX) - everything initialises fine but when I drag a row, whilst it moves within the tabl

4条回答
  •  [愿得一人]
    2021-01-03 06:01

    In datatable initialization code, remove order attribute. If we use order then drag and drop will not work.

    Example with order - not working

    table = $('#ConfigMenuTable').DataTable({
      data: testData,
      "rowReorder":  {
                    selector: 'td:nth-child(1)'
                },            
      "order":[[ 1, "asc" ]],
      "columns": [
                    {"visible": false},                         
                    {"width": "20%", "className": 'reorder'},                       
                    {"visible": false,"searchable": true, "width": "15%"},     
                    {"orderable": false, "searchable": false},  
                    {"orderable": false, "searchable": false},
                    {"orderable": true, "searchable": false}                
                ]
    
    });
    

    Example without order - working

    table = $('#ConfigMenuTable').DataTable({
      data: testData,
      "rowReorder":  {
                    selector: 'td:nth-child(1)'
                }, 
      "columns": [
                    {"visible": false},     
                    {"width": "20%", "className": 'reorder'},   
                    {"visible": false,"searchable": true, "width": "15%"},  
                    {"orderable": false, "searchable": false},
                    {"orderable": false, "searchable": false},
                    {"orderable": true, "searchable": false}                
                ]    
    });
    

提交回复
热议问题