hide rows with search

hide rows with search

gicugicu Posts: 14Questions: 5Answers: 0

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

  • kthorngrenkthorngren Posts: 21,132Questions: 26Answers: 4,918

    I would look at using a Search Plugin. In the plugin you can check the two columns for 0 and if true use return false; otherwise return true; for all other rows.

    Kevin

  • gicugicu Posts: 14Questions: 5Answers: 0

    ok, but this is creating a function. I want to compose this after loading the table, automatically.
    How do I execute the plugin function?

  • gicugicu Posts: 14Questions: 5Answers: 0

    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?

  • kthorngrenkthorngren Posts: 21,132Questions: 26Answers: 4,918

    but this is creating a function. I want to compose this after loading the table, automatically.
    How do I execute the plugin function?

    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.

    but when I create the pdf, the deleted rows are shown in the pdf. why?

    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

This discussion has been closed.