{"id":466,"date":"2007-07-05T18:51:11","date_gmt":"2007-07-05T18:51:11","guid":{"rendered":"http:\/\/www.bartbusschots.ie\/blog\/?p=466"},"modified":"2014-08-04T15:40:31","modified_gmt":"2014-08-04T15:40:31","slug":"simple-sortable-tables","status":"publish","type":"post","link":"https:\/\/www.bartbusschots.ie\/s\/2007\/07\/05\/simple-sortable-tables\/","title":{"rendered":"Simple Sortable Tables"},"content":{"rendered":"<p>Despite the advent of broadband excessive round-trips to the server still slow websites down. Having to send a request to the server to get the same data again but in a different order each time someone wants to sort a table is just not efficient. Hence, what you want is some nice simple JavaScript to do it for you. Ideally this JavaScript should be cross-browser and should not require you to make any substantive changes to your mark-up. Well, the good news is that this ideal has been realized and has been released under the free and open source <a href=\"http:\/\/en.wikipedia.org\/wiki\/MIT_License\" target=\"_blank\">MIT License<\/a>. I&#8217;m talking about Stuart Langridge&#8217;s <a href=\"http:\/\/kryogenix.org\/code\/browser\/sorttable\/\" target=\"_blank\">Sorttable<\/a>.<\/p>\n<p>Assuming you use proper XHTML markup for your tables, in particluar <code>thead<\/code> and <code>tbody<\/code> tags, making your tables sortable is a two-step process:<\/p>\n<ol>\n<li>Include <code>sorttable.js<\/code><\/li>\n<li>Set the class of the tables you want sortable to <code>sortable<\/code><\/li>\n<\/ol>\n<p>For a basic setup that&#8217;s it! If you want to get a little more fancy you can by doing things like making some columns un-sortable but that too is trivially easy. Honestly, I have no complaints at all about this script, it just works!<\/p>\n<p>[tags]XHTML, tables, sortable tables, JavaScript[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Despite the advent of broadband excessive round-trips to the server still slow websites down. Having to send a request to the server to get the same data again but in a different order each time someone wants to sort a table is just not efficient. Hence, what you want is some nice simple JavaScript to [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,16],"tags":[420],"series":[],"class_list":["post-466","post","type-post","status-publish","format-standard","hentry","category-computers-tech","category-programming","tag-javascript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7t9xK-7w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":1,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":7415,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/466\/revisions\/7415"}],"wp:attachment":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/tags?post=466"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/series?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}