[Rails-spinoffs] table sorting/manipulation library?

Felipe Gasper
Wed, 14 Sep 2005 20:32:09 -0000

I have a library I''ve developed that I believe is the most flexible and
useful table sorting/striping/row-selecting library around.

Big features:
Single and multiple-level sort
Arbitrary sort criteria (IP address, date, etc.)
Works with table headers that are > 1 row or column large
Stripe tables and/or enable row selecting
Row selecting supports drag-select and SHIFT-click
No extra HTML; all CSS and Javascript
Optionally creates buttons: "Default Sort", "Select all",
etc.
Quite fast
Pretty good cross-browser support (AFAIK)

All the other table-sorting libraries I''ve found try to
"guess" what
they''re sorting. This library makes no attempt to do so, instead
assuming the designer can tell it how to sort by giving it a function
for each sortable column that returns a value to be sorted.

An example:

-----------------
<table id="myTable" class="sortable striped
rowsSelectable">
string number date


..........




document.getElementById(''myTable'').sorterFuncs = [
	String,
	Number,
	function(str) {
		var dateSplit = str.split(/\D/);

		//assume we''re in MM/DD/YYYY format
		return (dateSplit[2] * 10000)
		   + (dateSplit[0] * 100)
		   + (str[1] * 1);
	}
];

----------------------

That''s it. Our table now correctly sorts by clicking on the table
headers.
If you want, add "multisort" to the table''s class, and you
get the
equivalent of multiple "ORDER BY" arguments to an SQL statement.

Is there interest around in a library like this?

-Felipe Gasper
Cincinnati, OH

--
Felipe M. L. Gasper, conductor/singer
http://felipegasper.com

Judge ideas, not people.
Love people, not ideas.