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 :-)

RSSComments

You must login to post comments. Login
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxJavaE20ME45E20andE20FlashE20E4citeE20eE78pertE20inE20ForumE20NokiaE20AmericasE2cE20MountainE20ViewE2eE20BesidesE20mobileE20technologiesE2cE20interestedE20inE20HCIE20andE20theE20useE20ofE20technologyE20inE20sportsE2eE20harttiE20E7cE2026E20SeptemberE2cE202008E2004E3a16E20ItE20hasE20beenE20againE20aE20fewE20monthsE20sinceE20myE20lastE20postE2eE20AE20fewE20monthsE3fE20E52eallyE3fE3fE3fE20E28TimeE20fliesE2cE20IE20haveE20toE20agreeE2eE2eE2eE29E20AnyhowE2cE20itE20hasE20beenE20evenE20longerE2cE20wayE20longerE2cE20sinceE20IE20didE20anythingE20onE20theE20WebE20developmentE20sideE2eE20MyE20oldE20petE20projectE20E28nationalE20teamE20statisticsE20forE20UltimateE20FrisbeeE2eE2eE2eE20maybeE20moreE20aboutE20thatE20inE20aE20laterE20postE29E20hE2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fblogE2fharttiE2dsuomelasE2dforumE2dnokiaE2dblogE2f2008E2f09E2f26E2ftableE2dsortingE2dwithE2djavascriptX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxHarttiE20SuomelaE27sE20ForumE20NokiaE20BlogE20E7cE20TableE20sortingE20withE20JavaScriptX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfnTypeZBlogContentQ qdcZtypeQUqfnTypeZBlogE45ntryQ qdcZtypeQUqfnTypeZCommunityContentQ qdcZtypeQUqfnTypeZE52esourceQ qdcZtypeQUqfnTypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxJavaE20ME45E20andE20FlashE20E4citeE20eE78pertE20inE20ForumE20NokiaE20AmericasE2cE20MountainE20ViewE2eE20BesidesE20mobileE20technologiesE2cE20interestedE20inE20HCIE20andE20theE20useE20ofE20technologyE20inE20sportsE2eE20harttiE20E7cE2026E20SeptemberE2cE202008E2004E3a16E20ItE20hasE20beenE20againE20aE20fewE20monthsE20sinceE20myE20lastE20postE2eE20AE20fewE20monthsE3fE20E52eallyE3fE3fE3fE20E28TimeE20fliesE2cE20IE20haveE20toE20agreeE2eE2eE2eE29E20AnyhowE2cE20itE20hasE20beenE20evenE20longerE2cE20wayE20longerE2cE20sinceE20IE20didE20anythingE20onE20theE20WebE20developmentE20sideE2eE20MyE20oldE20petE20projectE20E28nationalE20teamE20statisticsE20forE20UltimateE20FrisbeeE2eE2eE2eE20maybeE20moreE20aboutE20thatE20inE20aE20laterE20postE29E20hE2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fX qfnZtopicQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fFNE2d1E2fBlogTopicE2fgeneralXRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZbrowsingQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZwebE5ftechnologyQRqmarsZrelevanceQNx100X qfnZtypeQUqfnTypeZBlogContentQ qfnZtypeQUqfnTypeZBlogE45ntryQ qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZE52esourceQ qfnZtypeQUqfnTypeZWebpageQ qfnZupdatedQDx2008E2d09E2d26X qfnZuserE5ftagQSxbrowsingX qfnZuserE5ftagQSxwebE2dtechnologyX qmarsZdescriptionQSxJavaE20ME45E20andE20FlashE20E4citeE20eE78pertE20inE20ForumE20NokiaE20AmericasE2cE20MountainE20ViewE2eE20BesidesE20mobileE20technologiesE2cE20interestedE20inE20HCIE20andE20theE20useE20ofE20technologyE20inE20sportsE2eE20harttiE20E7cE2026E20SeptemberE2cE202008E2004E3a16E20ItE20hasE20beenE20againE20aE20fewE20monthsE20sinceE20myE20lastE20postE2eE20AE20fewE20monthsE3fE20E52eallyE3fE3fE3fE20E28TimeE20fliesE2cE20IE20haveE20toE20agreeE2eE2eE2eE29E20AnyhowE2cE20itE20hasE20beenE20evenE20longerE2cE20wayE20longerE2cE20sinceE20IE20didE20anythingE20onE20theE20WebE20developmentE20sideE2eE20MyE20oldE20petE20projectE20E28nationalE20teamE20statisticsE20forE20UltimateE20FrisbeeE2eE2eE2eE20maybeE20moreE20aboutE20thatE20inE20aE20laterE20postE29E20hE2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfnTypeZBlogContentQ qrdfZtypeQUqfnTypeZBlogE45ntryQ qrdfZtypeQUqfnTypeZCommunityContentQ qrdfZtypeQUqfnTypeZE52esourceQ qrdfZtypeQUqfnTypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ