Easy way of programmatically filtering in DataTable
Easy way of programmatically filtering in DataTable
![juliandrea85](https://secure.gravatar.com/avatar/01770aed76db4015e197d765979d912c/?default=https%3A%2F%2Fvanillicon.com%2F01770aed76db4015e197d765979d912c_200.png&rating=g&size=120)
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!
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!
This discussion has been closed.
Replies
Allan
I've called fnFilter and works fine :-)
Thank you!