rows().every() only by array of indexes

rows().every() only by array of indexes

itajackassitajackass Posts: 162Questions: 48Answers: 3
edited July 2018 in Free community support

I've a datatables where i've to some calculation.

but only some row i need to read, by an index array.

For example if i've an array like: var arr = [0,1,3,5]; i need to loop inside the table limited for rows: 0,1,3,5 only.

Is it possible to use a function like: table.rows({[0,1,3,5]}).every() ?

My fiddle to implement http://jsfiddle.net/bbLjzspf/5398/

Answers

  • itajackassitajackass Posts: 162Questions: 48Answers: 3

    Important: I know i can loop all rows and check if the rowIdx is in array arr to do my calc., but for some problems/variables I omitted in this example, I can't used this method. I need to limit loop only!

  • itajackassitajackass Posts: 162Questions: 48Answers: 3
    edited July 2018

    Ok this works:

    var arr = [0,1,3,5];
    
    myTable.rows(arr, { order: 'applied' }).every(function ( rowIdx, tableLoop, rowLoop ) {
    
     alert(rowIdx);
    
    });
    
This discussion has been closed.