在XWIKI中的#livetable宏中自定义过滤条件

下面这段文字是在#livetable的在线文档中的示例描述:

 

参见:http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HFilterorganizationsbydomain

 

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 }}
此示例感觉写得有点文不对题,实际上通常我们使用过滤时会根据实际对象(如例子中的OrganizationClass的文档中的对象)的属性进行过滤,比如现在有类:XWiki.DanJuSummaryClass,有属性version(字符串),需要表格展示所有version属性值为V7.0的文档出来怎么写过滤条件呢?
参考如下示例,在新建的页面中(如上面例子中的MySpace.ListOrganizationJSON页面)
{{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 是XWIKI中的所有字符串属性存储实体,最后一个条件obj.id=sp.id很重要,相当于SQL中的关联条件,没有这个条件过滤逻辑是不正确的,则结果也不正确。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值