Jess McKenzie Jess McKenzie - 1 month ago 16
Ajax Question

Sorting Tabulated Data

For example if I have a table with some data in it.


  • What would be the best way to be able to sort this information via a date picker?

  • How could I make this table accept information from an Ajax or JSON feed if required?



I have been given the following question hence my query regarding the question above:

In HTML display a set of tabular data where the data contains dates. Implement a date picker that filters the tabular data. Where possible allow for the tabular data to be supplied via ajax or json feeds.


Answer

Like @Tats_innit said in the comment you can use tabsorter plugin to accomplish this. Using this plugin is easy, after loading the js files just use this

$('table.bordered').tablesorter({
    // include zeba widgets
    widgets: ['zebra'],
    sortList: [[0, 0], [2, 0]]
});

Working fiddle

It detect date columns automatically and sort according to date orders.

You can check how can you append ajax fetched data into it here

http://tablesorter.com/docs/example-ajax.html

Comments