Wiki source code of Live Table component

Version 59.1 by ElenaOanaTabaranu on 2009/09/14

Hide last authors
ElenaOanaTabaranu 58.1 1 = Live Table component =
fkorteby 27.1 2
ElenaOanaTabaranu 58.1 3 {{velocity filter="none"}}
4 {{html clean="false" wiki="true"}}
fkorteby 27.1 5 #warning("This section documents a feature that is only available starting with XWiki Enterprise 1.9M2.")
6
ElenaOanaTabaranu 58.1 7 {{toc start="" depth="" numbered=""/}}
fkorteby 27.1 8
ElenaOanaTabaranu 58.1 9 == Summary ==
fkorteby 27.1 10
ElenaOanaTabaranu 58.1 11 The **"Live Table"** component is a dynamic table loading data lazily using ajax requests as the user browse the table, in order to scale easily the display of very large amounts of data. Users can browse the table thanks to a pagination system. Filters on columns are available to search for specific entries. Columns can be made sortable in both direction. The video below demonstrate the main capabilities of the live table component:
12 <p/>
13 {{{<object width="640" height="401"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4474332&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4474332&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="401"></embed></object>}}}
fkorteby 27.1 14
ElenaOanaTabaranu 58.1 15 == How to use ==
fkorteby 27.1 16
ElenaOanaTabaranu 58.1 17 The Live Table component is made available in several ways to [[Applications>>code:Applications.WebHome]] developers and developers of the [[XWiki platform and products>>dev:Main.WebHome]], depending on their specific needs. The simplest, and most of the times preferred, way to embed a Live Table component is to use the <tt>livetable</tt> velocity macro, available in all pages of your wiki. With only one call to this macro, you will be able to display a live table of the data of your choice! For more specific needs, in the cases you need more control on the table behavior, or to build another component on top of the live table, it is possible to instantiate the live table from JavaScript. In this case, you, as opposed to the velocity macro, you will need to construct the HTML elements the JavaScript component expects yourself, either from JavaScript, either writing the [[HTML directly in your wiki page>>platform:Main.XWikiSyntax]]
fkorteby 27.1 18
ElenaOanaTabaranu 58.1 19 === Using the Velocity <tt>livetable</tt> macro ===
fkorteby 27.1 20
ElenaOanaTabaranu 58.1 21 Please refer [[Live Table Macro>>code:Macros.LiveTableMacro]] reference.
fkorteby 27.1 22
ElenaOanaTabaranu 58.1 23 === HTML + JavaScript ===
fkorteby 27.1 24
ElenaOanaTabaranu 58.1 25 This is a dynamic component which must me used carefully because of performance issues. The HTML content of the Live Table is automatically updated using Javascript and [[JSON>>http://www.json.org]] code generated with the [[Live Table Macro>>code:Macros.LiveTableMacro]].
fkorteby 27.1 26
ElenaOanaTabaranu 58.1 27 === Example ===
ElenaOanaTabaranu 30.1 28
29 The Live Table component could be extended with a special column containing the ratings of some documents from the wiki.
ElenaOanaTabaranu 58.1 30 The first step would be to generate the JSON code of the column we want to add. In order to achieve this goal we need to modify the result page of the velocity live table macro with our custom page **TutorialsCode.LiveTableRatings**:
ElenaOanaTabaranu 32.1 31
ElenaOanaTabaranu 58.1 32 {{code}}
ElenaOanaTabaranu 56.1 33 test
ElenaOanaTabaranu 55.1 34 #set($collist = ["doc.name", "_ratings", "doc.date", "doc.author", "_actions"])
ElenaOanaTabaranu 52.1 35
ElenaOanaTabaranu 57.1 36 #set($colprops = {
ElenaOanaTabaranu 32.1 37 "doc.name" : { "type" : "text" , "size" : 30, "sortable":true, "filterable":true},
38 "_ratings" : { "sortable":false},
39 "doc.date" : { "type" : "date" },
40 "doc.author" : { "type" : "text", "link" : "author"},
ElenaOanaTabaranu 51.1 41 "_actions" : { "actions": ["copy","delete","rename","rights"]}
ElenaOanaTabaranu 57.1 42 })
43 #set($options = { "resultPage":"TutorialsCode.LiveTableRatings",
44 "tagCloud" : true,
45 "translationPrefix" : "xe.index.",
46 "rowCount": 10 })
47 #set($ok = $xwiki.ssx.use("TutorialsCode.LiveTableRatings"))
48 #set($ok = $xwiki.jsx.use("TutorialsCode.LiveTableRatings"))
49 #livetable("alldocs" $collist $colprops $options)
ElenaOanaTabaranu 58.1 50 {{/code}}
ElenaOanaTabaranu 32.1 51
ElenaOanaTabaranu 35.1 52 If we want to display the rated documents from a certain space, e.g. Tutorials, the last parameter of the <tt>#gridresultwithfilter</tt> must contain the query we need.
ElenaOanaTabaranu 58.1 53 {{/html}}
54 {{/velocity}}
ElenaOanaTabaranu 34.1 55
ElenaOanaTabaranu 58.1 56 {{code}}
ElenaOanaTabaranu 34.1 57 #includeMacros("TutorialsCode.LiveTableResultsMacros")
ElenaOanaTabaranu 59.1 58
ElenaOanaTabaranu 34.1 59 #gridresultwithfilter("" $request.collist.split(",") "" "doc.space='Tutorials' and doc.name<>'WebHome' and doc.name<>'WebPreferences'")
ElenaOanaTabaranu 59.1 60
61 {{/code}}{/pre}

Get Connected