How to loop through all rows in DataTables jQuery?

这一生的挚爱 提交于 2019-11-30 01:46:26

I finally found:

 var data = table.rows().data();
 data.each(function (value, index) {
     console.log(`For index ${index}, data value is ${value}`);
 });

Datatables have an iterator for each row rows().every() with this referring to the context of the current row being iterated.

tableName.rows().every(function(){
    console.log(this.data());
});

If you are using the legacy DataTables then you can get all the rows even the paginated ones, as shown below...

table.fnGetNodes(); // table is the datatables object.

So we can loop through the rows by using .each() method provided by jQuery.

jQuery(table.fnGetNodes()).each(function () {
// You can use `jQuery(this).` to access each row, and process it further.            
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!