New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

backgrid-advanced-filter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backgrid-advanced-filter

Advanced filter for backgrid

0.1.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

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

  • Backgrid filter

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.

Keywords

backgrid

FAQs

Package last updated on 06 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts