You Are Here:

Community: Blogs

Hartti Suomela's Forum Nokia Blog

Table sorting with JavaScript

hartti | 26 September, 2008 04:16

It has been again a few months since my last post. A few months? Really??? (Time flies, I have to agree...)

Anyhow, it has been even longer, way longer, since I did anything on the Web development side. My old pet project (national team statistics for Ultimate Frisbee... maybe more about that in a later post) has been suffering with crappy coding (naturally by yours truly) for years, and especially there has been no data updates for about 2 years (even though there has been quite a few games played within that period).

Last week I finally got some statistics updated online, and this week I started tinkering with my old code (undocumented of course... painful...). My first task was to find a way to sort HTML tables with JavaScript, so the users do not always need to wait for sorted data retireval from the server. The first script I bumped into was sorttable by Stuart Langridge. With this nifty script it was extremly easy to change the tables to use JavaScript based sorting: I just included the JavaScript code on the pages and added class="sortable" attribute in my HTML tables. (Ok. Ok. I also removed the old sorting links from the table header row and added some style definitions in the site's css-file, but that's it). Lo and behold, the table sorting worked. Very powerful and easy!

Unfortunately for me, the script lacked one important feature. It turned out to be impossible to create a header column for the data rows, which would not be sorted (row headers / row numbering). And off I went for some more googling.

After a few disappointments, I finally found a useful JavaScript library which solved my problem: Google Visualization API. Man, that API is powerful. It provided a very good solution for me for my table sorting problem (although it means a little more work for me, as I am forced to some more coding to change my direct HTML table code to use the JavaScript-based tables that the API uses), but it also contains very cool visualization tools (check for example Motion Chart and Annotated Time Line in the Gallery). Sure, I have not yet checked the licencing rights, which are likely a little stricter that what sorttable has, but I do not think this will cause any problems for my hobby project. And no, I have not yet taken this into use - that's the task for tomorrow I guess :-)

 
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZrelationQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fschemasE2fnokiaE2fFNE2d1E2e58E2eowlX qdcZtitleQSxForumE20NokiaE20BlogsE20WebE20SiteXLen qdcZtitleQSxForumE20NokiaE20BlogsE20WebE20SiteXLen qdcZtypeQUqfnZE44istributionQ qdcZtypeQUqfnZSiteQ qdcZtypeQUqvocZTermQ qdcZtypeQUqvocZVocabularyConstructQ qdcZtypeQUqwebZSiteQ qdcZtypeQUqrdfsZE52esourceQ qswZserviceQUxhttpE3aE2fE2fswE2enokiaE2ecomE2furiE71aX quriE71aZserviceQUxhttpE3aE2fE2fswE2enokiaE2ecomE2furiE71aX qvocZpartOfQUqfnZPublicationQ qwebZserviceQUxhttpE3aE2fE2fswE2enokiaE2ecomE2furiE71aX qrdfZtypeQUqfnZE44istributionQ qrdfZtypeQUqfnZSiteQ qrdfZtypeQUqvocZTermQ qrdfZtypeQUqvocZVocabularyConstructQ qrdfZtypeQUqwebZSiteQ qrdfZtypeQUqrdfsZE52esourceQ qrdfsZisE44efinedByQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fschemasE2fnokiaE2fFNE2d1E2e58E2eowlX qrdfsZlabelQSxForumE20NokiaE20BlogsE20WebE20SiteXLen qrdfsZlabelQSxForumE20NokiaE20BlogsE20WebE20SiteXLen qrdfsZseeAlsoQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fschemasE2fnokiaE2fFNE2d1E2e58E2eowlX