473,659 Members | 3,592 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 1612

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.len gth <= 1) return;
var itm = ts_getInnerText (table.rows[1].cells[column]);
sortfn = ts_sort_caseins ensitive;
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_currenc y;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric ;
SORT_COLUMN_IND EX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.ro ws[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.ro ws.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*********@bl ueyonder.co.uk> skrev i meddelandet
news:Qm******** ***********@new s-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.len gth <= 1) return;
var itm = ts_getInnerText (table.rows[1].cells[column]);
sortfn = ts_sort_caseins ensitive;
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_currenc y;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric ;
SORT_COLUMN_IND EX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.ro ws[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.ro ws.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
7641
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, $tdream); $query_rstdream = "SELECT * FROM albums ORDER BY `year` ASC"; $rstdream = mysql_query($query_rstdream, $tdream) or die
0
2618
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 header row - and they conflict. The sortable column apparently uses the generic style for <a> elements and the rest of the header uses "headerRow". Can anyone tell me how to get consistent styles for each column in my datagrid header?
1
1950
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 does not keep the rows, as usual, but holds the single _columns_ as lists. In this case, every column could have it's own datatype, just like database-tables and could be sortable by the list's sort function.
3
3537
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 can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
1
1553
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 sortable product listings such as shown on such sites? I am already able to get CSV into sortable (by javascript) HTML tables that do not use databases, but there are problems with this such as the slow sort time when there are many items, the...
1
1192
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
16958
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 examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.