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

exgrid

v1.0.9

Published

extremely powerful yet extensible gird component

Downloads

10

Readme

Exgrid

NPM version Dependency Status Build Status Coverage Status

Try it now

Exgrid has rebuild with reactive-lite, beside flexable binding methods and binding resue for excellence performance, it can do:

  • paging
  • sorting
  • filter
  • local/remote mode
  • custom formatter/render
  • data change reactive
  • event delegation

Install

with npm

npm install exgrid --save

Usage

Define a template like this:

<table>
  <thead>
    <tr>
      <th class="sort" data-sort="name">name</th>
      <th class="sort" data-sort="age">age</th>
      <th>company</th>
      <th class="sort" data-sort="number">money</th>
      <th>active</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="left">{name}</td>
      <td style="width:30px;">{age}</td>
      <td class="left">{company}</td>
      <td class="money">¥{money | currency 2}</td>
      <td data-render="setActive" class="center"></td>
    </tr>
  </tbody>

The last tr element in tbody is used as the template for repeat rendering.

Init the grid, render it to html and set data:

var grid = new Grid(template, {
  perpage: 10,
  // filters for reactive-lite
  filters: {
    percentage: function (val) {
      return (val*100).toFixed() + '%'
    }
  },
  // bindings for reactive-lite
  bindings: {
    react: function (prop) {
      this.bind('$stat', function (model, el) {
        ...
      })
    }
  },
  // delegate object for reactive-lite
  delegate: {
    setActive: function (model, el) {
      ...
    }
  }
})
// use local mode
grid.local()
// render element
placeholder.appendChild(pager.el)
grid.setData(data)

Events

  • sort emit with params when remote sort needed (including sortField sortDirection)
  • filter emit with params when remote filter needed (including filterField filterValud)
  • page emit with params when remote paging needed (including curpage, perpage)
  • change emit after table row add or removed
  • remove emit just before this component removed

##API

Grid(el, [option])

  • el table element or template string as root node
  • option optional option for list-render
  • option.perpage max page count perpage, works with pager (need Object.definePropety support)
  • option.delegate delegate object for reactive
  • option.bindings bindings object for reactive
  • option.filters filters object for reactive
  • option.model model class used for generate model
  • option.empty String or Element rendered in parentNode when internal data list is empty
  • option.limit the limit number for render when setData() (equal to perpage if not set)

Exgrid inherits all methods from list-render, the extra methods are shown below

.bind(type, selector, handler)

Delegate event type to selector with handler, handler is called with event and a reactive model

.local()

Make list works on local model, which means sort, filter and paging only happens locally

.sort(field, dir, [method])

Sort the data by field, direction or method, when it's remote mode(default mode), emit event only

.filter(field, val|function)

Filter the data by field, val or function, when it's remote mode(default mode), emit event only

.select(n)

Select page n, when it's remote mode(default mode), emit event only

.setTotal(n)

Set total data count for paging, can not used for local mode

.remove()

Unbind all events and remove the created elements

License

The MIT License (MIT)

Copyright (c) 2015 Qiming Zhao [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.