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

backgrid-jquery-autocomplete-cell

v0.1.2

Published

A Backgrid extension that adds support for jQuery Autocomplete as a cell editor

Downloads

5

Readme

backgrid-jquery-autocomplete-cell

A Backgrid extension that adds support for jQuery Autocomplete as a cell editor

When an autoComplete cell enters edit mode it will render a jQuery Autocomplete widget with a list of options allowing the user select an item using either the keyboard or mouse.

This cell was built as a replacement for the standard Backgrid select-cell which IMHO doesn't behave very well.

Installation

npm install --save backgrid-jquery-autocomplete-cell

Usage

The Backgrid jQuery Autocomplete cell defines a new cell type autoComplete.

The list of options is controlled via the attribute autoCompleteOptions. This attribute is similar to the jQuery Autocomplete source attribute. It supports hardcoded data in the column definition in the form of ["abc", ...] or [{label: "", value: ""}, ...]. In addition the autoCompleteOptions attribute can also be a function which returns an Ajax deferred object. The deferred response must be in the same form as described above.

If you are working with an API which provides data in another form you can also define a parse attribute which will be used in the deferred response to parse the response into a form which is accepted by the Autocomplete cell.

Basic example

  • Define the cell as an autoComplete.
  • Set array of options in autoCompleteOptions attribute.
var grid = new Backgrid.Grid({
  columns: [{
      label: "Name",
      name: "name",
      cell: "string"
  }, {
      label: "Country",
      name: "country",
      cell: "autoComplete",
      autoCompleteOptions: ["America", "Canada", "Denmark", "England", "Ireland", "Japan", "New Zealand", "Spain"]
  }]
});

Deferred example

  • Define the cell as an autoComplete.
  • Set autoCompleteOptions attribute as function which returns an array containing the options.
var grid = new Backgrid.Grid({
  columns: [{
      label: "Name",
      name: "name",
      cell: "string"
  }, {
      label: "Country",
      name: "country",
      cell: "autoComplete",
      autoCompleteOptions: ["America", "Canada", "Denmark", "England", "Ireland", "Japan", "New Zealand", "Spain"]
  }, {
      label: "Post Code",
      name: "post_code",
      cell: "autoComplete",
      autoCompleteOptions: function() {
        return $.get({
          url: "/api/post_codes?country=" + this.model.get("country"),
          dataType: "json"
        });
      }
  }]
});

Parse example

  • Define the cell as an autoComplete.
  • Set autoCompleteOptions attribute as function which returns an array containing the options.
  • Set a parse attribute as function which will parse the deferred response.
var grid = new Backgrid.Grid({
  columns: [{
      label: "Name",
      name: "name",
      cell: "string"
  }, {
      label: "Country",
      name: "country",
      cell: "autoComplete",
      autoCompleteOptions: function() {
        return $.get({
          url: "/api/countries",
          dataType: "json"
        });
      },
      parse: function(response) {
        return response.countries;
      }
  }]
});