Difference between revisions of "16 May 2007"

From Organic Design wiki
(News: Sortable tables)
 
(he supports alternate bg colour in his sortable tables, updated example to demonstarte)
Line 1: Line 1:
 
{{news|title=MediaWiki Sortable Tables|img=|msg=
 
{{news|title=MediaWiki Sortable Tables|img=|msg=
It says in [[M:Help:Sorting]] that [[w:MediaWiki|MediaWiki]] version 1.9.x now has native support for sortable tables. But actually the method they're using is fully a [[w:client-side JavaScript|client-side JavaScript]] solution developed [http://www.joostdevalk.nl/code/sortable-table here] by [http://www.joostdevalk.nl/about-me Joost de Valk]. So by adding the source code to your [[MediaWiki:Common.js]] article (and enabling it by setting ''$wgUseSiteJs'' to true in your [[MW:LocalSettings.php|LocalSettings.php]] file) any wiki can do it. this will compliment the new [[MW:Extension:Display Filter|display filter]] and [[MW:Extension:UploadCSV|upload CSV]] extensions perfectly. here's an example:
+
It says in [[M:Help:Sorting]] that [[w:MediaWiki|MediaWiki]] version 1.9.x now has native support for sortable tables. But actually the method they're using is fully a [[w:client-side JavaScript|client-side JavaScript]] solution developed [http://www.joostdevalk.nl/code/sortable-table here] by [http://www.joostdevalk.nl/about-me Joost de Valk]. So by adding the source code to your [[MediaWiki:Common.js]] article (and enabling it by setting ''$wgUseSiteJs'' to true in your [[MW:LocalSettings.php|LocalSettings.php]] file) any wiki can do it. this will compliment the new [[MW:Extension:Display Filter|display filter]] and [[MW:Extension:UploadCSV|upload CSV]] extensions perfectly. The following example also demonstrates another useful feature which is the alternate striped background colours making the table much easier to read, these stripes are maintained regardless of the sorting order of the table.
  
{{{!}} class="wikitable sortable" id=foo
+
{{{!}} class="sortable" id=foo style="border: solid 1px #aaa"
 
{{!}}-
 
{{!}}-
! style="background: #CCCCCC; color:#000000;border:solid 1px #808080;" {{!}}City  
+
! style="background: #ccc;" {{!}}City  
! style="background: #99CCCC; color:#000000;border:solid 1px #608080;" {{!}}January<br/><span style="font-size:90%;">(Low)</span>
+
! style="background: #ccc;" {{!}}January<br/><span style="font-size:90%;">(Low)</span>
! style="background: #99CCCC; color:#000000;border:solid 1px #608080;" {{!}}January<br/><span style="font-size:90%;">(High)</span>
+
! style="background: #ccc;" {{!}}January<br/><span style="font-size:90%;">(High)</span>
! style="background: #D99898; color:#000000;border:solid 1px #996B6B;" {{!}}July<br/><span style="font-size:90%;">(Low)</span>
+
! style="background: #ccc;" {{!}}July<br/><span style="font-size:90%;">(Low)</span>
! style="background: #D99898; color:#000000;border:solid 1px #996B6B;" {{!}}July<br/><span style="font-size:90%;">(High)</span>
+
! style="background: #ccc;" {{!}}July<br/><span style="font-size:90%;">(High)</span>
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Amman]]
+
{{!}}[[Amman]]{{!}}{{!}}4&deg;C{{!}}{{!}}12&deg;C{{!}}{{!}}18&deg;C{{!}}{{!}}32&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}4&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}12&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}18&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}32&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Baghdad]]
+
{{!}}[[Baghdad]]{{!}}{{!}}0&deg;C{{!}}{{!}}16&deg;C{{!}}{{!}}24&deg;C{{!}}{{!}}43&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}0&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}16&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}24&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}43&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Cairo]]
+
{{!}}[[Cairo]]{{!}}{{!}}8&deg;C{{!}}{{!}}18&deg;C{{!}}{{!}}21&deg;C{{!}}{{!}}36&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}8&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}18&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}21&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}36&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Damascus]]
+
{{!}}[[Damascus]]{{!}}{{!}}0&deg;C{{!}}{{!}}12&deg;C{{!}}{{!}}16&deg;C{{!}}{{!}}36&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}0&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}12&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}16&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}36&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Dubai]]
+
{{!}}[[Dubai]]{{!}}{{!}}15&deg;C{{!}}{{!}}23&deg;C{{!}}{{!}}30&deg;C{{!}}{{!}}39&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}15&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}23&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}30&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}39&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Jerusalem]]
+
{{!}}[[Jerusalem]]{{!}}{{!}}5&deg;C{{!}}{{!}}13&deg;C{{!}}{{!}}17&deg;C{{!}}{{!}}31&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}5&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}13&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}17&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}31&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Riyadh]]
+
{{!}}[[Riyadh]]{{!}}{{!}}8&deg;C{{!}}{{!}}21&deg;C{{!}}{{!}}26&deg;C{{!}}{{!}}42&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}8&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}21&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}26&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}42&deg;C
 
 
{{!}}-
 
{{!}}-
{{!}} style="text-align:center; background: #F2F2F2; color:#000000;font-size:90%;border:solid 1px #808080;padding:.3em;" {{!}}[[Tehran]]
+
{{!}}[[Tehran]]{{!}}{{!}}-3&deg;C{{!}}{{!}}7&deg;C{{!}}{{!}}22&deg;C{{!}}{{!}}37&deg;C
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}-3&deg;C
 
{{!}} style="text-align:center; background: #E6F2F2; color:#000000;font-size:90%;border:solid 1px #608080;" {{!}}7&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}22&deg;C
 
{{!}} style="text-align:center; background: #F2E6E6; color:#000000;font-size:90%;border:solid 1px #996B6B;" {{!}}37&deg;C
 
 
{{!}}}
 
{{!}}}
 
*See [[M:Help:Sorting]] for details about syntax and usage
 
*See [[M:Help:Sorting]] for details about syntax and usage
 
*Get the JavaScript code from [http://www.joostdevalk.nl/code/sortable-table www.joostdevalk.nl/code/sortable-table]
 
*Get the JavaScript code from [http://www.joostdevalk.nl/code/sortable-table www.joostdevalk.nl/code/sortable-table]
 
}}
 
}}

Revision as of 06:21, 16 May 2007

Warning.svg This is a blog item that needs to be converted to the new Bliki format


MediaWiki Sortable Tables

It says in M:Help:Sorting that MediaWiki version 1.9.x now has native support for sortable tables. But actually the method they're using is fully a client-side JavaScript solution developed here by Joost de Valk. So by adding the source code to your MediaWiki:Common.js article (and enabling it by setting $wgUseSiteJs to true in your LocalSettings.php file) any wiki can do it. this will compliment the new display filter and upload CSV extensions perfectly. The following example also demonstrates another useful feature which is the alternate striped background colours making the table much easier to read, these stripes are maintained regardless of the sorting order of the table.

City January
(Low)
January
(High)
July
(Low)
July
(High)
Amman 4°C 12°C 18°C 32°C
Baghdad 0°C 16°C 24°C 43°C
Cairo 8°C 18°C 21°C 36°C
Damascus 0°C 12°C 16°C 36°C
Dubai 15°C 23°C 30°C 39°C
Jerusalem 5°C 13°C 17°C 31°C
Riyadh 8°C 21°C 26°C 42°C
Tehran -3°C 7°C 22°C 37°C