【发布时间】:2015-11-20 11:42:22
【问题描述】:
我们在 sapUI5 探索的演示中使用 openUI5 中的 JSON 视图,他们使用此 xml 视图作为分组列表
<mvc:View
controllerName="sap.m.sample.ListGrouping.List"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}"
headerText="Products" >
<StandardListItem
title="{Name}"
description="{ProductId}"
icon="{ProductPicUrl}"
iconDensityAware="false"
iconInset="false" />
</List>
</mvc:View>
我们将它翻译成这个 json 视图,但是排序器和标头工厂被忽略了。项目按预期显示
{
"Type": "sap.ui.core.mvc.JSONView",
"controllerName": "company.controller.XY",
"content": [
{
"Type" : "sap.m.List",
"height" : "100%",
"items" : {
"path" : "/ProductCollection",
"sorter" : {
"path" : "SupplierName",
"descending" : false,
"group" : true
},
"groupHeaderFactory" : ".getGroupHeader",
"template" : {
"Type" : "sap.m.StandardListItem",
"title" : "{Name}",
"description" : "{ProductId}",
"icon" : "{ProductPicUrl}",
"iconDensityAware" : false,
"iconInset" : false
}
}
}
]
}
如何将 xml 视图转换为 json 视图? 是否有任何工具可以自动执行此操作?
【问题讨论】:
-
控制器名称:company.controller.XY - 嗯?你知道我相信这里的惯例吗?
-
我很确定控制器没有命名为
XY。除此之外,命名空间方案对我来说似乎很好。我们使用de.companyname.productname.controller.XY -
@Bernard 我知道这一点,但我不得不掩盖公司 + 控制器名称
-
您是否已经为您的分拣机尝试过这个:
"sorter" : new sap.ui.model.Sorter("SupplierName", false,true);这是它的 API 文档sap.ui.model.Sorter -
@Christoph 感谢您的建议,但不幸的是您不能直接在 JSON/XML 视图中使用构造函数