npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grid-filter

v0.5.4

Published

Filter Tool for Grid Component

Downloads

5

Readme

Build Status npm version Join the chat at https://gitter.im/icanjs/grid-filter

grid-filter

A filter tool for the grid-component.

Filter is a tool for grid-component designed to filter a list on entered search terms. Its built with CanJS and StealJS, and can be used for CanJS stack including DoneJS (http://donejs.com). Component updates isHidden property of list items to toggle visibility.

The UI part of the filter uses jQuery Tokeninput plugin.

If your grid uses parent-child expandable rows then grid-fiter can also perform a search inside the child rows. If a match is found in one of the child rows then the parent row with all child rows will be shown.

Filter Demo Filter Demo2

Filter logic

Filter will go through the searchable attributes of each item and update isHidden attribute of the item if all of the searchTerms are found.

Searchable attributes are defined as:

  • a list of attributes from the columns config (coma-separated);
  • if no columns is defined then all item attributes;
  • exclude attributes defined in exclude-columns config;
  • if children-prop attribute presents then child items will participate in the search for the parent row; if a match is found in one of the child rows then the parent row with all child rows will be shown.

Installation

npm install grid-component --save

To check out the demo:

  • run http server on the root of the project;
  • load the demo file in browser (src/demo/demo.html).

Usage

<grid-filter {(rows)}="rows"></grid-filter>

<grid-filter {(rows)}="rows"
             columns="title,amount"
             {^search-terms}="searchTerms"></grid-filter>

<ul>
 {{#each rows}}
   <li class="{{#if isHidden}}hidden{{/if}}">{{region}}, {{country}}, {{amount}}</li>
 {{/each}}
</ul>

Full grid example

<grid-component {(rows)}="items">

  <div class="grid-tools">

    <grid-filter {(rows)}="rows"></grid-filter>

  </div>

  <table>
    <thead>
      <tr>
        <th ($click)="{sortBy 'title'}">Title {{{sortArrow 'title'}}}</th>
        <th ($click)="{sortBy 'amount'}">Amount {{{sortArrow 'amount'}}}</th>
      </tr>
    </thead>

    <tbody>
      {{#each rows}}
        <tr class="{{^if isVisible}}hidden{{/if}}">
          <td>{{title}}</td>
          <td>{{amount}}</td>
        </tr>
      {{/each}}
    </tbody>
  </table>
</grid-component>

API

  • rows: can.List to apply filtering to.
  • columns: coma-separated list of columns to filter on. Default is all columns.
  • exclude-columns: a list of item attributes to ignore for searching.
  • search-terms: a list of search terms entered into filter box.
  • children-prop: an attribute to look for child rows. Default is "children".