hide rows with search
hide rows with search

After loading a table, I would like to hide a whole row if the text of 2 columns equals 0. How is it done?
This discussion has been closed.
After loading a table, I would like to hide a whole row if the text of 2 columns equals 0. How is it done?
Answers
I would look at using a Search Plugin. In the plugin you can check the two columns for
0
and if true usereturn false;
otherwisereturn true;
for all other rows.Kevin
ok, but this is creating a function. I want to compose this after loading the table, automatically.
How do I execute the plugin function?
i solved withs this code:
rowCallback: function( row, data, index ) {
if ((data[1] == "0,00 €") &&( data[2] == "0,00 €" )){
$(row).hide();
}
}
but when I create the pdf, the deleted rows are shown in the pdf. why?
The search plugin executes each time the table is drawn. Here is a simple example hiding the rows that have
Edinburgh
as the Office.http://live.datatables.net/yisaqore/6/edit
Note that it happens on table load. The function is also run when the table is searched or sorted. You can see this in the browser's console.
You are not using Datatables API's to hide the rows. This is not recommended as Datatables has no knowledge of this. Datatables doesn't have the concept of hiding rows. This is done through using one of the search API's or the search plugin.
Kevin