Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI5 XML View vs JSON View Grouped List

Tags:

json

xml

sapui5

We are using JSON views in openUI5 in the sapUI5 explored demo they use this xml view for their grouped list

<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>

We translated it to this json view but the sorter and the header factory is ignored. The items are displayed as expected

{
   "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
               }
           }
       }
   ]
}

How to transform the xml view to a json view? Is there any tool out there which is doing this automaticly?

like image 661
deterministicFail Avatar asked Nov 20 '15 11:11

deterministicFail


1 Answers

I just reported your issue on github.
According to SAP-Developers this is a recognized JSON-View Bug.

...the JSONView currently doesn't properly resolve controller methods. This is a known gap in the JSONView, which unfortunately still hasn't been closed although it was detected already back in June (JSONViews are not used that much...).

The only choice you have is to create a sap.m.List.items-Binding in your Controller via Javascript or switch your View declaration to either Javascript- or XML-Views.

like image 194
B. Kemmer Avatar answered Nov 15 '22 20:11

B. Kemmer