Skip to content

Seaforth/meteor-jquery-datatables

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery DataTables Build Status

Sort, page, and filter millions of records.

Reactively.

This package wraps the powerful and mature DataTables.net jQuery plugin for enhancing HTML tables.

DataTables.net features

  • Variable length pagination
  • On-the-fly filtering
  • Multi-column sorting with data type detection
  • Smart handling of column widths
  • Display data from almost any data source
  • Scrolling options for table viewport
  • Fully internationalisable
  • jQuery UI ThemeRoller support
  • Rock solid - backed by a suite of 2900 unit tests
  • Wide variety of plug-ins inc. Editor, TableTools, FixedColumns and more

Usage

All you have to do is include the datatable component in one of your templates like so:

{{> dataTable
    selector=browsers.selector
    columns=browsers.columns
    collection=browsers.collection
    options=browsers.options
    subscription=browsers.subscription
    query=browsers.query
}}

Then setup the data in your controller or as template helpers:

if (Meteor.isClient)
  Template.home.browsers = {
    columns: [
      {
        sTitle: "Engine",
        mData: "engine"
      },
      {
        sTitle: "Browser",
        mData: "browser"
      },
      {
        sTitle: "Platform",
        mData: "platform"
      },
      {
        sTitle: "Version",
        mData: "version",
        sClass: "center"
      },
      {
        sTitle: "Grade",
        mData: "grade",
        sClass: "center",
        mRender: function (dataSource, call, rawData) {
          if (rawData == null) rawData = "";
          switch rawData.grade
            when "A" then return "<b>A</b>"
            else return rawData.grade
          if (rawData.grade === "A") return "<b>A</b>";
          return rawData.grade;
        }
      },
      {
        sTitle: "Created",
        mData: "createdAt",
        mRender: function (dataSource, call, rawData) {
          if (rawData.createdAt == null) rawData.createdAt = "";
          if (rawData.createdAt)
            return moment(rawData.createdAt).fromNow()
          else 
            return rawData.createdAt || "";
      },
      {
        sTitle: "Counter",
        mData: "counter"
      }
    ],
    selector: "dataTable-browsers",
    collection: Browsers,
    subscription: "all_browsers",
    options: {
      oLanguage: {
        sProcessing: "You must construct additional pylons!"
      }  
    },    
    query: {
      grade: "A"
    }  
  }

On the server side, you need to publish the data:

if (Meteor.isServer) {
  DataTable.debug = "true";
  DataTable.publish("all_browsers", Browsers);
}

Styling

This package DOES NOT PROVIDE ANY STYLES OR ASSETS intentionally.

If you would like some help styling datatables you can check out my luma-ui package or the DataTables.net official docs.

Contributing

About

Sort, page, and filter millions of records reactively.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CoffeeScript 97.0%
  • JavaScript 2.1%
  • CSS 0.9%