Datatable : A jQuery plugin for dynamics table

Published on jquerydatatableajax

Why another datatable plugin?


Why another "datatable" plugin while there are a lot of existing plugin?

Well, i just needed such a plugin for one of my project and plugins I found searching the web were not as customizables as I wanted (for example, I cannot specified how I want a line to be rendered). I am clearly not claiming this is the best datatable plugin on the web, but here are some of its strengths:

  • No dependencies (pure javascript only!).
  • Easy to use - You can transform an existing HTML table in a datatable in one line!
  • Extremely customizable.

A simple example


Let's have a look at a simple example on this looong (okay, not so long... ) table :

Firstname Lastname
Linus Torvalds Computer Science
Brian Kernighan Computer Science
Blaise Pascal Mathematics
Larry Page Computer Science
Richard Hamming Mathematics
Grace Hopper Computer Science
Pierre Bezier Mathematics
Shigeru Miyamoto Computer Science
Leslie Lamport Computer Science
Rasmus Lerdorf Computer Science
Xavier Leroy Computer Science
Albert Einstein Physics
Bill Gates Computer Science
Leonard De Vinci Mathematics
Pierre De Fermat Mathematics
René Descartes Mathematics
Alan Turing Computer Science
Ada Lovelace Computer Science
Isaac Newton Physics
Carl Friedrich Gauss Mathematics
John Von Neumann Computer Science
Claude Shannon Mathematics
Tim Berners-Lee Computer Science
Richard Stallman Computer Science
Dennis Ritchie Computer Science
Bjarne Stroustrup Computer Science
Steve Jobs Computer Science

If you click on this button, you'll see how powerfull the plugin is:

The code used to tranform the table (Quite short!):

var datatable = new DataTable(document.getElementById('simple-example-table'), {
    pageSize: 6, 
    filters: [true, false, 'select'], 
    filterText: 'Search... ',
    sort: [true, true, false], 
    sortKey: 0
});

Where can I find the plugin?


The plugin can be found on github at the following address: https://github.com/Holt59/datatable. If you have encounter some issues using it, or if you want new features to be available, do not hesitate to post on this article or to send me an e-mail.

How to use the plugin?


Well, just put the files on your website, and add this line to your html page:

<script type="text/javascript" src="js/datatable.min.js"></script>

To apply the plugin on your table, just add:

var table = document.getElementById('MyTable');
var options = { /* ... */ };
var datatable = new DataTable(table, options) ; 

See available options at: http://holt59.github.io/datatable.

The code is under license Apache v2.