I populate a table with a JSON data like this:
{
'id' : 1,
'name': 'Jhon',
'category_id': 12,
},
{
'id' : 3,
'name': 'Max',
'category_id': 12,
},
{
'id' : 4,
'name': 'Bob',
'category_id': 23,
}
I can select a row this way
table.row({id:3})
But I can't use this for select many rows
table.rows({category_id:12})
This return ALL rows, without filter
category_id:12
I read the doc at https://datatables.net/reference/type/row-selector and this doesnt help.
I found a this comment and was a similar behavior, but I want know if this is overthinking and I'm doing something wrong.
var rowIndexes = []; table.rows( function ( idx, data, node ) { if(data.somefield === somevalue){ rowIndexes.push(idx); } return false; });
I use this.
let rowIndexes = [];
table.rows( function ( idx, data, node ) {
if(data.category_id === 12){
rowIndexes.push(idx);
}
return false;
});
let myrows = table.rows(rowIndexes);