how to build a custom filter plugin
how to build a custom filter plugin
WestFarmer
Posts: 1Questions: 1Answers: 0
hi, I am using DataTables against a server side api wihch support filtering data like this:
{
// ... other options
filter : {
logic : 'and', filters : [{
field : 'userId', operator : 'equals', value : 'foo'
},{
field : 'userName', operator : 'contains', value : 'jack'
}]
}
}
I want to add a 'filter' button before the search box, when user click that button, a filter form will be popped up, let user to choose filter operation from 'equals contains startsWith ...', and fill in filter value, then apply the filters.
how can I do this ?
This discussion has been closed.
Answers
This example shows how you might add custom elements into the toolbars. Another option would be to create a feature plug-in, or perhaps to use Buttons.
Use
ajax.reload()
to reload the data for the table when the filter changes andajax.data
to get the data for the filter to submit to the server.Allan