Is there a Filter Event?

Is there a Filter Event?

tdevoe@acord.orgtdevoe@acord.org Posts: 21Questions: 8Answers: 2

I would like to hook into a filter event which would clear the selected rows. The user would then select only from the filtered results. These results would be submitted. I've read through a # of threads and it looks like it may not be available in the current release. If not, does anyone have a work around?

Thanks.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,813Questions: 1Answers: 10,517 Site admin
    Answer ✓

    I don't really understand what you mean by "clear the selected rows". Do you want to remove the selected row and then submit what remains? Is it an Ajax submit or a regular <form> submit?

    Allan

  • tdevoe@acord.orgtdevoe@acord.org Posts: 21Questions: 8Answers: 2

    First of all I may be confusing a Filter with the Search box that "filters" the results to the user in the table. I believe DataTables has a Filter feature which is not the same as the Search feature which allows the user to find specific rows from the table has already been populated. I will use the term "filtered" to mean the Search box that is directly above the results which allows a user to see a subset of result rows.

    The scenario is the following:
    1. The user searches and results are returned.
    2. They select multiple items.
    3. They then type in a criteria in the Search ("filtered") which displays a subset of rows. They only want to submit the rows that were selected in the "filtered" results. There are still rows that were selected in the table but are not being displayed because of the "filtering". However, all of the rows that were selected - including ones that are not part of the "filtered" rows are still part of the selection and are submitted.

    I would like to grab only the selected rows that are part of the "filtered" results. I was looking for an event that would allow me to deselect all when criteria is typed into the Search ("filtered") field.

    I just want to say that your product is great as well as the support and documentation.

    Thanks for your help.
    Tom

  • allanallan Posts: 63,813Questions: 1Answers: 10,517 Site admin
    Answer ✓

    I would like to grab only the selected rows that are part of the "filtered" results.

    table.row( { search: 'applied' } ).nodes(). See the selector-modifier and rows() API documentation.

    Regards,
    Allan

  • tdevoe@acord.orgtdevoe@acord.org Posts: 21Questions: 8Answers: 2

    That worked beautifully. I was able to combine the "applied" and "selected" selector to the results and it pulled just the selected records from the visible results (searched).

    $('#grid').DataTable().rows({ search: 'applied', selected: true }).data()
    

    Thanks again for your help.
    Tom

This discussion has been closed.