Wrong result If count rows which contain a word
Wrong result If count rows which contain a word

Hello,
i have the problem, if i count rows that contain a word, the result is multiplied by 4 (Table has four columns), maybe someone can give me a tip what i missed:
"ajax": "array.txt",
"createdRow": function(row, data, dataIndex) {
var filteredData = dtable.column(1).data().filter( function ( value, index ) {
return includes("Word") ? true : false;
} );
document.getElementById('result').value = filteredData2.count(); // Works perfect
var filteredData2 = dtable.data().filter( function ( row ) {
return row.includes("Word") ? true : false;
} );
document.getElementById('result2').value = filteredData2.count(); // Result is multiplied by 4 (Table has four columns)
}
This discussion has been closed.
Replies
The
count()
docs state this:If you have 4 columns then the result of
filteredData2
will be a 2D array of 4 x the number of rows. Checkout this example:http://live.datatables.net/lavaduwu/1/edit
Also you are missing
value.includes()
on line 5.Kevin
Thanks for your help, i will try it.