jquery - JQuery数据表的rowReorder问题

标签 jquery datatable

为什么当 rowReorder 为 false 时,第一列行号不更新,而当 rowReorder 为 true 时,只有行的第一列重新排序,但行的位置没有改变?

var table = $('#tbldynamic').DataTable( {
                orderCellsTop: true,
                fixedHeader: true,
                "scrollY":        "400px",
                "scrollCollapse": true,
                "paging":         false,
                scrollCollapse: true,
                scrollX: true,
                "ordering": false,
                fixedColumns:   {
                    leftColumns: 0,
                    rightColumns: 0
                },
                rowReorder: {
                    update: false
                },
                'createdRow': function(row, data, dataIndex){
                    $(row).attr('id', 'row-' + dataIndex);
                }
            } );

When rowReorder is false

When rowReorder is true

最佳答案

我使用这个js在我最近的项目中进行重新排序

https://www.jqueryscript.net/table/jQuery-Plugin-To-Reorder-Table-Rows-Via-Drag-Drop-Orderable.html

这里有直播Demo

对于您的解决方案,您可以使用onOrderFinish

onOrderFinish:function (element) { console.info('I\'ve finished reordering! Selected unit: ', element) },

在此事件中,您可以重写该 td block

关于jquery - JQuery数据表的rowReorder问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58949565/

相关文章:

php - 在脚本中使用 php

c# - 并发冲突 : the UpdateCommand affected 0 of the expected 1 records

javascript - jQuery Datatable,将文本框的值输出到选定行的列

javascript - 如何在jquery函数中使用多个处理程序

javascript - 根据排序或不更改光标样式

javascript - jQuery DataTables - 子行和 "Undefined is Not a Function"

javascript - jQuery 数据表 : Sort on one column when clicking on another.

javascript - 允许用户在文本框中仅添加空格且电话号码不超过 11 个

R Shiny - 使用 DataTable 移动列名

javascript - 达到10行后如何触发DataTables中的下一个按钮