olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.7k stars 818 forks source link

(Wishlist) addFilter and removeFilter function signature #1193

Closed mateddy closed 6 years ago

mateddy commented 6 years ago

Currently the function accept three parameters: field, type and value: $("#example-table").tabulator("addFilter", "age", ">", 22); $("#example-table").tabulator("removeFilter", "age", ">", 22);

Is it possible to have it accept one parameter (object) with three properties? $("#example-table").tabulator("addFilter", {field:"age", type:">", val:"22");

If so it would be more convenient to modify existing ilter as follows: let f = $("#example-table").tabulator("getFilters").find(e => e.field == "age"); $("#example-table").tabulator("removeFilter", f); f.value = 30; $("#example-table").tabulator("addFilter", f);

mateddy commented 6 years ago

I quickly realized that it might not a good idea for ajaxFiltering... my program makes two ajax request instead of one.

olifolkerd commented 6 years ago

Hey @mateddy

you can pass an array into the addFilter function to add multiple filters in one go, you could also just pass an array with one object into the function:

$("#example-table").tabulator([{field:"age", type:">", value:52}]);

I hope that helps,

Cheers

Oli :)

mateddy commented 6 years ago

Actually I wish to be more convenient in replacing filters. At this moment I need to search, remove and add new filter.