loop every row and column

loop every row and column

marcpiratmarcpirat Posts: 51Questions: 18Answers: 0
edited September 2018 in Free community support

hi

I need to create a json object of the content of the table. Need to take some data-field to put in the json object.

What happen if table is response? Could have a row who are splitted on two rows...

What should be the best way to do it?

thanks

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @marcpirat ,

    Probably the best way is to use rows().every(), as in this example on that page:

    table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
        var data = this.data();
        // ... do something with data(), or this.node(), etc
    } );
    

    If your case, the "do something" would be to add to that JSON object.

    Cheers,

    Colin

This discussion has been closed.