jQuery DataTables - Access all rows data

前端 未结 4 421
既然无缘
既然无缘 2021-02-04 06:51

I\'m using jQuery DataTables and want to copy all rows (save in JavaScript array) upon clicking the header checkbox.

I want to find where jQuery DataTab

4条回答
  •  一生所求
    2021-02-04 07:43

    SOLUTION

    There are many methods that could be used for that purpose. You can use rows().data() to get the data for the selected rows.

    Example:

    var table = $('#example').DataTable();
    
    var data = table
        .rows()
        .data();
    
    alert( 'The table has ' + data.length + ' records' );
    

    DEMO

    See this jsFiddle for code and demonstration.

提交回复
热议问题