0.1.0 • Published 10 years ago

backgrid-advanced-filter v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Backgrid advanced filter

An advanced filter plugin for Backgrid. Online demo

Example usage

Initialization

    // Create advanced filter instance
    var advancedFilter = new Backgrid.Extension.AdvancedFilter.Main({
      collection: dataCollection,
      /*
        Filterable columns need an additional attribute 'filterType'.
        e.g.: filterType: 'string';  (Supported: string, number, boolean, percent)
      */
      columns: columnCollection,
      /* optional */
      filters: filterCollection
    });

    // Render the filter
    $(document.body).append(advancedFilter.render().$el);

    // Available events
    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) {
        // Get filter definition (default is mongo style)
        var definition = filterModel.exportFilter("mongo");
        
        // Or get it as string
        var definitionString = filterModel.exportFilter("mongo", true);
        
        // Request new data using filter
        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.

0.1.0

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago