Backgrid advanced filter
An advanced filter plugin for Backgrid.
Online demo
Example usage
Initialization
var advancedFilter = new Backgrid.Extension.AdvancedFilter.Main({
collection: dataCollection,
columns: columnCollection,
filters: filterCollection
});
$(document.body).append(advancedFilter.render().$el);
advancedFilter.on("filter:new", function(filterId, filterModel) {
console.log("New filer created.");
});
advancedFilter.on("filter:save", function(filterId, filterModel) {
console.log("Currently active filter saved.");
});
advancedFilter.on("filter:apply", function(filterId, filterModel) {
console.log("Filter apply requested");
});
advancedFilter.on("filter:cancel", function(filterId, filterModel, stateBeforeCancel) {
console.log("Changes made to current filter reverted.");
});
advancedFilter.on("filter:reset", function(filterId, filterModel) {
console.log("Current active filter reset");
});
advancedFilter.on("filter:remove", function() {
console.log("Currently active filter removed.");
});
Filtering
advancedFilter.on("filter:apply", function(filterId, filterModel) {
var definition = filterModel.exportFilter("mongo");
var definitionString = filterModel.exportFilter("mongo", true);
dataSource(filter).success(function(filteredData) {
dataCollection.reset(filteredData);
});
});
Dependencies
Contributing / development
- Fork this repository
- Checkout locally using git
- Run
npm install
- Run
gulp
to watch for changes and build + test the library
- Edit files in
/src
+ add/adjust tests
- Make sure lint and tests pass
- Commit to your fork and create a PR (Pull request) with the changes
Authors
This project is developed and maintained by Wilbert van de Ridder and sponsored by Solodev.