<> = Sortable Tables = '''Short description''' ## Tell your story here. ## What is the problem you are trying to solve? ## Is this features useful to most users or just to specific users? Tables are very useful for displaying information in a concise way. What often can be useful is sorting of tables which to my knowledge isn't possible with MoinMoin. Since this feature could certainly be useful for most users. Hint: MediaWiki adds a sorting feature to tables via a JavaScript (see http://meta.wikimedia.org/wiki/Help:Sorting). == CSS Parser == . I have a CSV-parser on http://linuxwireless.org/ that adds this by using the databrowser widget. -- JohannesBerg <> . That parser was added recently to 1.7. . Actually, I was too quick, the new parser can just '''filter''', not '''sort'''. -- JohannesBerg <> == Sorting with sorttable == [[http://www.kryogenix.org/code/browser/sorttable/|sorttable]] is a piece of JavaScript that will make tables sortable by clicking on their headers. To use it, apply these patches: * [[attachment:hg-export-1.diff]] This does not make all tables sortable; it integrates with the [[MoinDev/DatasetBrowser|databrowser widget]]. Only columns that are marked `sortable` in the dataset's `columns` list will become sortable. Current issues: * If a page includes two `DataBrowserWidget`s then `sorttable.js` will be processed twice. * If the columns in a `DataBrowserWidget` are filterable then clicking on the field list to perform filtering triggers the sorting mechanism. This should be fixable by modifying `sorttable.js`. = Discussion = * I would prefer a function in the databrowser widget. So other macros can maybe benefit and sort the ouput (e.g. for MacroMarket/PageDicts) * see here for "another way" to sort tables MacroMarket/SortBy If the sorttable.js is appended to common.js it does always load once per page. You have to set then only `` e.g. {{{ ||Name ||email ||irc || }}} . I have patched the browser.py in my 1.7.2 installation and added the sorttables.js to the htdocs pool. However, the script still did not load and I don't see why. But following Reimar's advise, the problem seems to be solved in a much simpler way when you just append the script code to common.js. -- MichaelDecker <> . For 1.8 I add that patch [[attachment:common.js.patch]] by `patch -p1 < common.js.patch` -- ReimarBauer <> . This patch works fine with 1.9.2. -- TakeoKatsuki <> == IE8 Problems == If this is used on an SSL site, the following code will cause a popup security warning on every page. {{{ /* for Internet Explorer */ /*@cc_on @*/ /*@if (@_win32) document.write(" ''' % {"url_prefix_static": url_prefix_static} }}} because the gui editor will forget a custom attribut like tableid you need to add this patch to your "text_html_text_moin_wiki.py" file. But be aware this is not heavy tested (only with latest 1.9.3 release), so no idea if there are any minor side effects hanging around... {{{#!highlight diff --- MoinMoin/converter/text_html_text_moin_wiki.py 2010-08-31 23:09:36.176215107 +0200 +++ MoinMoin/converter/text_html_text_moin_wiki.py 2010-09-08 22:53:14.873040813 +0200 @@ -1036,6 +1036,8 @@ result.append('tablestyle="%s"' % node.getAttribute("style")) if node.hasAttribute("class"): result.append('tableclass="%s"' % node.getAttribute("class")) + if node.hasAttribute("id"): + result.append('tableid="%s"' % node.getAttribute("id")) return " ".join(result).strip() def _row_style(self, node): }}} now you just need to add the class sortable and some id to your table, to enable the sorting feature, for example: {{{ || Surename || Lastname || || Lee || Paul || || John || Deer || || Peter || Parker || }}} Infos: * With some optional css you could additional add some better layout to your tables.. just add them into your common.css file. * Some little more features are available, see here: http://yoast.com/articles/sortable-table/tutorial/ {{{#!wiki note Be aware, the last update of this javascript is 2007, and future MoinMoin Version will be for sure using some jquery stuff. so this stuff will maybe not work with the upcoming moin 2.0. }}} Demo:: http://rock.heavy.ch/Administration/Projekt/Ideen Author:: -- MarcelHäfner <> === Feedbacks === * Line 94 of the sortable.js states {{{ var i = 0; }}} . This cause a problem in telling the right type of the column, change 0 to 1 fix this. ... == ImprovedTableParser == The [[ParserMarket/ImprovedTableParser|ImprovedTableParser]] provides sortable tables, although the syntax is not quite the same as the classic Moin table syntax (it's slightly more flexible). -- PaulBoddie <> == MoinMoin 2.0 == {{{ moin-2.0 has jquery which can bes used for table sorters but widget table will need a rewrite there and jquery modules for sorting aren't implemented yet too }}} ---- CategoryFeatureRequest