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

时间:2015-11-20 11:42:22

标签: json xml 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>

我们将其翻译为此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视图? 是否有任何工具可以自动执行此操作?

1 个答案:

答案 0 :(得分:8)

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

  

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

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

相关问题