Easy way of programmatically filtering in DataTable

Easy way of programmatically filtering in DataTable

juliandrea85juliandrea85 Posts: 2Questions: 0Answers: 0
edited October 2012 in General
Hi,
I've registered at the forum only for share a solution I found, for a problem I had for days about filtering a Datatable from code.
I've tried afnFiltering.push with no success, because I wasn't able to restore the table to their original data.
My code is as below:

var filterCtrl= $("#myDatatable_filter :input"); //locate DOM element input (it will be the input SEARCH field) inside the div "myDatatable_filter"... in both Firefox and IE, the div containing the filter renders this way
filterCtrl.val("my Value to search for"); //value to the input "SEARCH"
filterCtrl.keyup(); //Fire event key up, for the search to work

I hope this help somebody,
Bye!

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Why not just call fnFilter ? The API method is there specifically to allow programmatic filtering.

    Allan
  • juliandrea85juliandrea85 Posts: 2Questions: 0Answers: 0
    Thanks! I was going crazy trying to use afnFiltering.push,
    I've called fnFilter and works fine :-)

    Thank you!
This discussion has been closed.