为什么服务器端 DataTable 上的 rows() 不是函数?

Why is rows() on a server-side DataTable not a function?

为什么 rows() 不是服务器端数据表上的函数?

除此之外,这些表格工作正常。

我之前在其他五个客户端数据表上使用过rows(),没有任何问题。

var tableComputerAndDevice = $('#tableComputerAndDevices').dataTable({
    searching: true,
    processing: true,
    serverSide: true,
    language: {
        "processing": '<div style="background-color:#eee"> <span class="fa fa-spinner fa-pulse fa-5x"> </span> </div>'
    },
    ajax: {
        url: url,
        data: data,
        type: "POST"
    },
    columns: [
        { "data": "checkbox", "searchable": false },
        { "data": "ComputerName", "searchable": true },
        { "data": "LastContact", "searchable": true }
    ]
});

var nodes = tableComputerAndDevice.rows('.selected').nodes();
console.log('nodes: ' + nodes);

错误:类型错误:tableComputerAndDevice.rows不是函数

是的,您判断正确。您需要将 dataTable 更改为 DataTable

还要说明dataTable和DataTable是有区别的

The difference between the two is that the first will return a jQuery object, while the second returns a DataTables API instance.

dataTable 更改为 DataTable。我回答我自己的问题,因为我花了一个小时解决这个错误,所以我希望我能帮助别人。

var tableComputerAndDevice = $('#tableComputerAndDevices').DataTable({