Hello Friends,
Anyone know tell me the best library or framework to implement a
table with automatic sorting of columns? There are several such as
FlexGrid, but would like to know what is the fastest and powerful.
You don't need a library, the principle is fairly simple and depending
on your requirements, might be less than 50 lines of code - a little
more if you want to include sorting numbers and dates. It's often
implemented as a single listener on the table, but can also use a row
in the thead and tfoot sections.
There are a number of table sorting scripts around, it's one of those
things typically attempted when confidence with the DOM is thought
sufficient. Search the archives and post what you come up with.
You'll need to define what "automatic" means and whether you are
sorting the columns (left to right I suppose) or sorting rows by the
values in a particular column.
It helps if each column is put into a colgroup, it saves iterating
over the rows to get the column's cell values. It also helps for
sorting columns as the entire colgroup can be moved rather than the
individual cells in each row.