Customize filter conditions in # livetable macro in XWiki
The following text is an example description in # livetable's online document: see here.
Filter organizations by domain
The organization class in the example below has two properties: an org_name of type String and an org_domain of type StaticList. the organization domain can have values like Software or Hardware, which will be used in the live table as filter options.
# Set ($ columns = ["org_name", "org_domain"])
# Set ($ columnsProperties = {
"Org_name": {"type": "text", "size": 20, "link": "view "},
"Org_domain": {"type": "list", "class": "MySpace. OrganizationClass "}
})
# Set ($ options = {
"ResultPage": "MySpace. ListOrganizationJSON ",
"TranslationPrefix ":"",
"RowCount": 10
})
# Livetable ("organization_directory" $ columns $ columnsProperties $ options)
The content of MySpace. ListOrganizationJSON (using syntax 2.0 ):
{Include document = "XWiki. LiveTableResultsMacros "/}}
{Velocity }}
# Gridresultwithfilter ("MySpace. organizationClass "$ request. collist. split (",") "" and doc. name <> 'organizationsheet 'and doc. name <> 'organizationtemplate '")
{/Velocity }}
In this example, the question is not correct. In fact, when filtering, we usually filter the attributes of the actual object (such as the object in the OrganizationClass document in this example). For example, there is a class: XWiki. danJuSummaryClass has the attribute version (string). The table shows all the documents whose version attribute value is V7.0. How can I write filter conditions?
Refer to the following example to create a page (for example, the MySpace. ListOrganizationJSON page in the above example)
{Include document = "XWiki. LiveTableResultsMacros "/}}
{Velocity }}
# Gridresultwithfilter ("XWiki. danJuSummaryClass "$ request. collist. split (",") ", StringProperty as sp" "and sp. name = 'version' and sp. value = 'v7. 0 'and obj. id = sp. id ")
{/Velocity }}
SringProperty is the storage object of all string properties in XWIKI, And the last condition obj. id = sp. id is very important. It is equivalent to the association condition in SQL. If the filtering logic without this condition is incorrect, the result is also incorrect.
XWiki installation tips
For installation and configuration of Linux + Tomcat + XWiki + MySQL, see
XWiki installation tutorial and language configuration change
Install Java open-source Knowledge Base XWiki in Windows
XWiki details: click here
XWiki: click here
This article permanently updates the link address: