Call fnFilter on a specific table (page with multiple tables)

Call fnFilter on a specific table (page with multiple tables)

smg6511smg6511 Posts: 12Questions: 2Answers: 0
edited February 2014 in DataTables 1.9
I've initiated a multi-table page with a typical call:
[code]
var oTables = $(".display").dataTable({...various config settings...});
[/code]
I've added a button to clear the filter field. On a page with only one table, I can clear this easily using:
[code]
oTables.fnFilter("");
[/code]
How can I apply that function to a specific table by index?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Use `$('#myTable').dataTable().fnFilter()` - i.e. an id selector to get a specific table.

    In DataTables 1.10 you can use the `tables()` method to specific a specific table from a multi-table instance: http://next.datatables.net/reference/api/table()

    Allan
  • smg6511smg6511 Posts: 12Questions: 2Answers: 0
    Thanks so much, Allan, for answering this so quickly. I did elect to make use of the table's position rather than IDing them by using jQuery's eq:
    [code]
    $("table.display:eq("+idx+")").dataTable().fnFilter("");
    [/code]
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Nice one - perfect solution :-)

    Allan
This discussion has been closed.