How to set custom header filter operator for ajax filtering?
See original GitHub issueHi Tabulator Team,
First of all thanks for your awesome work. I started using Tabulator a month ago and I started loving Tabulator.
I’m trying to pass a custom header filter operator for each column in my ajaxFiltering, but the filter params always returns like
value.
here is my scenario.
i’ll be sending my filters in the server url as follows:
https://localhost/api/test?search=name eq test&dob gt 12/12/2012&...
so in my columns definition,
{
title: 'Name',
field: 'name',
headerFilter: 'input',
headerFilterLiveFilter: false,
type: 'eq'
},
{
title: 'DOB',
field: 'dob',
headerFilter: 'input',
headerFilterLiveFilter: false,
type: 'gt',
},...
But my params.filters
array in ajaxURLGenerator
always returns type: "like"
for all the fields.
it would be nice if there is an option to make my params.filters
array to return the type I mention in the column definition of each column like type: "eq"
, type: "gt"
, etc…
Am I missing something from docs?
I searched and could’nt find a way. Help would be much appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
To my knowledge there’s not a way to register in new kinds of filters (though admittedly my knowledge is very limited). From looking at your examples though, it kind of seems like you’re looking to just translate the types over to a format your api accepts, not adding any unusual new kinds of filters. If that’s the case, you can iterate over the
params.filters
in theajaxURLGenerator
function like you mentioned and swap out the types, like so:Hey @fingers10 @tentus
Almost everything in Tabulator is customisable. everything is built as modules and pretty much anything where you pick from a list of built in options can be extended to add your own.
Custom Filter Function
You can either pass a callback into the headerFilterFunc which is covered in the Header Filter Documentation
Extend Filter Module
You can also expand Tabulator to add custom built in filters, checkout the Filter Module Docs for more information on how to do this,
You can then pass that string of the key into the headerFilterFunc to reference a specific filter.
Because this string is passed back in the ajax request if all you need it for is to pass back the string you can define the filter function as an empty callback and it will do what you need.
I hope that helps,
Cheers
Oli 😃