filtering by an array of id´s

filtering by an array of id´s

offroffoffroff Posts: 1Questions: 0Answers: 0
edited February 2012 in General
I will have a table where each row have a unique id. I would like to use an array of id´s to filter the table. Is there a smart way to do that?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    What you need to do is create a custom filter: http://datatables.net/development/filtering#row_filters - the normal DataTables filter doesn't have access to the TR element (since that would be horribly slow), hence the need for this method.

    In the function you have three parameter: oSettings, aData, iDataIndex. To get the TR element for each row you would do:

    [code]
    var nTr = oSettings.aoData[ iDataIndex ].nTr;
    [/code]

    then you've got the TR element and you can do a test against your array of ids and the TR's id and see if it should be included or not.

    Allan
This discussion has been closed.