How to correctly iterate cells and rows of dynamically created datatable with columns?

How to correctly iterate cells and rows of dynamically created datatable with columns?

msm_baltazarmsm_baltazar Posts: 59Questions: 22Answers: 0

hello friends,

I have a datatable with dynamically created columns. There is an html input box in the cells of this datatable. I want to check the value in each row of the datatable and in the cells of each row. How can I iterate this correctly?

Thanks in advance for your help.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    You can use the rows().every() to iterate all the rows. In the loop you can get the data for the row.

    Kevin

  • msm_baltazarmsm_baltazar Posts: 59Questions: 22Answers: 0

    I did it as below. thank you so much.

    $('#myTable').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
                    var rowNode = this.node();
                    $(rowNode).find("td.my-td").each(function () {
                        var cellData = $(this).html();
                        //do something
                    });
                });  
    
Sign In or Register to comment.