Jump to content

Jquery Tablesorter Plugin


Guest FirefoxRocks

Recommended Posts

Guest FirefoxRocks

This plugin is awesome: http://tablesorter.com/docs/Here is the description for it:

Introduction tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. It has many useful features including:
  • Multi-column sorting
  • Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
  • Support for ROWSPAN and COLSPAN on TH elements
  • Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)
  • Extensibility via widget system
  • Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+
  • Small code size

However I have a problem here. It doesn't explain how you can use the "parsers for sorting text, URIs, integers, ...". An example of how to invoke the parser is here: http://tablesorter.com/docs/example-meta-parsers.html, but I don't know where the parsers actually take place in the JavaScript (the names of them).I have a table with a column of dates in the format <?php date("j/M/Y"); ?> and it would be great if I could sort it properly.

Link to comment
Share on other sites

Just from looking at the example, I would imagine they do that in the class:

	<thead>> 		<tr> 			<th class="{sorter: 'text'}">first name</th> 			<th>last name</th> 			<th>age</th> 			<th>total</th> 			<th class="{sorter: 'procent'}">discount</th> 			<th>date</th> 		</tr> 	</thead>

Link to comment
Share on other sites

Guest FirefoxRocks

I tried that but the parser was still A-Z/0-9 (text/mixed/numbers), not dates. Even if I use a month name like "August" it still doesn't sort according to date.

Link to comment
Share on other sites

They have several examples showing dates that all work. They also have an example of writing your own parser to use for a certain column. You can see all of the normal parsers defined in the tablesorter.js file, it has 3 or 4 different date parsers for various types of dates.

Link to comment
Share on other sites

Guest FirefoxRocks

I finally figured out that if I don't use ISO dates, I have to use the US Long Date format, which was found in MSDN. But since that was too long, I dropped the weekday and forced the parser to use usLongDate.That took a while.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...