0.1.0 • Published 9 years ago

backgrid-advanced-filter v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 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

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago