Get row index based on multiple values

Get row index based on multiple values

mkirkpatrickmkirkpatrick Posts: 2Questions: 1Answers: 0
edited April 2016 in Free community support

I am trying to get the row (or the row index) where there are specific values in multiple columns. If it finds a row with the matching values, it returns the index; if not, return -1. What I have right now looks like this, but it's far too slow:

var existingRow = -1;
mappingTable.rows().every(function (rowIdx, tableLoop, rowLoop) {
    if(mappingTable.cell(rowIdx, 7).data() == foo
        && mappingTable.cell(rowIdx, 2).data() == bar
        && mappingTable.cell(rowIdx, 3).data() == baz
        && mappingTable.cell(rowIdx, 4).data() == qux) {
            existingRow = rowIdx;
            return;
    }
});
return existingRow;

With 3000+ rows, this is too slow. At first it seemed like I should be able to use mapping.columns([ ]).data().filter(), but that seems to filter each column separately, when I need to verify the combination of column values all within one row.

This discussion has been closed.