Coder Social home page Coder Social logo

guoping007 / dropdown-table-filter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rbayliss/dropdown-table-filter

1.0 1.0 0.0 119 KB

A jQuery plugin providing simple dropdown filters for table columns.

Home Page: http://rbayliss.net/jquery-dropdown-table-filter

License: GNU General Public License v2.0

JavaScript 100.00%

dropdown-table-filter's Introduction

jQuery Dropdown Table Filter plugin:

A simple to use plugin to add dropdown filters for any table. Filtering is instant and does not require a page reload.

HTML Structure:

Item # Type
Item 1 Special
Item 2 Not Special

This plugin requires a <th> for each column. The label for the <th> will be replaced by a dropdown select menu containing all of the unique values present in that column. In the above example, selecting "Special" for the type column would hide Item 2, leaving only item 1.

How To Use

It's simple. Just include ddtf.js (along with jQuery), and do:

$('#myTable').ddTableFilter();
To use the options defined below, use the following syntax:

    var options = {
      sortOpt: false,
      ...more settings here
    }
    $('#myTable').ddTableFilter(options); 

Options

For customization, the following parameters are available:

  • valueCallback: A function that provides the hidden value of the cell. This is useful if your cells don't just contain simple values.
  • textCallback: A function that provides the value of the cell that is displayed in the dropdown. Remember that HTML cannot be put into a dropdown option.
  • sortOptCallback: A function to sort the options as they are added to the list. This function will be passed two options to compare at a time.
  • transition: An object with 3 parameters:
    • hide: The function used to remove rows from view. (defaults to $.hide())
    • show: The function used to bring rows back into view. (defaults to $.show())
    • options: An array of options to pass to the above two functions. Typically, this would be something like ['slow'] for a normal jQuery hide transition.
  • emptyText: Text to display for empty rows. Defaults to '--Empty--'.
  • sortOpt: A boolean indicating whether or not to sort the options. This must be true for sortOptCallback to work. Defaults to true.
  • debug: A boolean indicating whether or not to run in "debug" mode. Debug mode displays performance data.
  • minOptions: Number of options required to show a select filter. Defaults to 2, meaning if a column only has one unique value, no select box will be shown (what would be the point?).

Compatibility

This plugin has been tested back to jQuery 1.2.6 and up to 1.4.2. It may work on other versions as well.

dropdown-table-filter's People

Contributors

rbayliss avatar andrewkharook avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.