简体   繁体   English

行重新排序数据 oldData 和 newData 上的数据表未定义

[英]Datatable on row-reorder data oldData and newData is undefined

I am currently rewriting my datatable from CodeIgniter (datatables v1.10.12 and RowReorder v1.1.2) to Laravel 6 (datatables v1.10.20 and RowReorder v1.2.6).我目前正在将我的数据表从 CodeIgniter(数据表 v1.10.12 和 RowReorder v1.1.2)重写为 Laravel 6(数据表 v1.10.20 和 RowReorder v1.2.6)。 On the event 'row-reorder' i need to collect data about the changes.在“行重新排序”事件中,我需要收集有关更改的数据。 Therefore i use this script.因此我使用这个脚本。

$('#category-table').on('row-reorder.dt', function (dragEvent, data, nodes) {
    var newSequences = [];

    $.each(data, function(key, change) {
        console.log(change);
        newSequences.push({
            id:         $(change.oldData).data('id'),
            sequence:   $(change.newData).data('sequence')
        });
    });

    doThingsWithTheResult(newSequences);
}

In the old situation (CodeIgniter) 'change.oldData' and 'change.newData' are filled with the old and new elements that are affected by the 'row-reorder' event but in the new situation (Laravel) both 'change.oldData' and 'change.newData' are 'undefined'.在旧情况(CodeIgniter)中,'change.oldData'和'change.newData'填充了受'row-reorder'事件影响的旧元素和新元素,但在新情况(Laravel)中,'change.oldData ' 和 'change.newData' 是'未定义的'。

旧/工作情况 Old/working situation旧/工作情况

新/非工作情况

New/ not working situation新/非工作情况

What could be the reason why these crucial properties are 'undefined'?这些关键属性“未定义”的原因可能是什么?

Problem solved!问题解决了!

Although it worked out-of-the-box in the old situation in de new situation i needed to add/provide the rowReorder.dataSrc setting.尽管它在新情况下在旧情况下开箱即用,但我需要添加/提供rowReorder.dataSrc设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM