473,506 Members | 17,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sortable Table

http://www.kryogenix.org/code/browser/sorttable/

On this page there's a link to a "sorttable.js"
(http://www.kryogenix.org/code/browse.../sorttable.js), but when I
open it the code's unformatted, I guess this is because he saved it on a
different OS? So does anyone have a proper formatted version for a Windows
XP user?
Jul 23 '05 #1
3 1600

dmsc17454_2 wrote in message
http://www.kryogenix.org/code/browser/sorttable/

On this page there's a link to a "sorttable.js"
(http://www.kryogenix.org/code/browse.../sorttable.js), but when I
open it the code's unformatted, I guess this is because he saved it on a
different OS? So does anyone have a proper formatted version for a Windows
XP user?


Well I managed to find this
http://www.webmaster-toolkit.com/fro...2Fsorttable.js.

Hopefully the output is correct :)
Jul 23 '05 #2
Ok, slight help need with editing this "sorttable.js" file. I have no
experience with Javascript

// Work out a type for the column
if (table.rows.length <= 1) return;
var itm = ts_getInnerText(table.rows[1].cells[column]);
sortfn = ts_sort_caseinsensitive;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
SORT_COLUMN_INDEX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

Basically, I want my dates to display like "12th May 2004" instead of
"12/5/2004", I think the code above is to do with this.
Jul 23 '05 #3
"dmsc17454_2" <dm*********@blueyonder.co.uk> skrev i meddelandet
news:Qm*******************@news-text.cableinet.net...
Ok, slight help need with editing this "sorttable.js" file. I have no
experience with Javascript

// Work out a type for the column
if (table.rows.length <= 1) return;
var itm = ts_getInnerText(table.rows[1].cells[column]);
sortfn = ts_sort_caseinsensitive;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
SORT_COLUMN_INDEX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

Basically, I want my dates to display like "12th May 2004" instead of
"12/5/2004", I think the code above is to do with this.


No, as the comment indicates, it uses regular expressions to guess what kind
of data the table contains based on how the content is formatted, then
assigns an appropriate sorting function (date, currency or numeric).

You might want to look up the javascript Date object. Probably you have to
parse the table cell content yourself and use it to initialize a Date with.
The Date can then be converted to text with various formatting options.

Joakim Braun
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
7607
by: Ian Rastall | last post by:
I'm doing a small project right now where I create a table from a database. This is the code, which Dreamweaver, for the most part, has written: *** <?php mysql_select_db($database_tdream,...
0
2611
by: cedoucette | last post by:
I just wrote code to support sortable columns in a datagrid. It seems to work fine; but, it doesn't look right. The problem is that I have a generic style for links and a different style for the...
1
1946
by: Henri Schomäcker | last post by:
Hi folks, what I need is a kind of 2D-Array which should, in the end, represent a typical html-table and which should be sortable by column. I thought of an implementation, where an vector...
3
3516
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
1
1545
by: vincemoon | last post by:
Sites such as download.com, dealtime.com, shopping.com, and tucows.com, feature impressive sortable lists of products. What software that imports CSV can be used to generate database-driven...
1
1188
by: grandslamforce | last post by:
Big deal for me, maybe the rest of you too: http://javascript.internet.com/miscellaneous/sortable-table-with-alternating-row-colors.html
1
16932
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.