UI5 XML视图与JSON视图分组列表

det*_*ail 9 xml json sapui5

我们在sUIUI5探索的演示中使用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>
Run Code Online (Sandbox Code Playgroud)

我们将其翻译为此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
               }
           }
       }
   ]
}
Run Code Online (Sandbox Code Playgroud)

如何将xml视图转换为json视图?是否有任何工具可以自动执行此操作?

B. *_*mer 8

我刚刚在github上报告了你的问题.
据SAP-Developers称,这是一个公认的JSON-View Bug.

... JSONView目前无法正确解析控制器方法.这是JSONView中的一个已知缺口,遗憾的是它虽然已经在6月份被检测到,但仍然没有被关闭(JSONViews没有那么多使用......).

您唯一的选择是sap.m.List.items通过Javascript在Controller中创建-Binding或将View声明切换为Javascript或XML-Views.