9

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?

deterministicFail
  • 1,271
  • 9
  • 28
  • controller name: company.controller.XY - huh? your are aware of convention here I trust? – Bernard Nov 21 '15 at 15:25
  • I am pretty sure the controller is not named `XY`. Apart from that the namespacing scheme seems fine to me. We use `de.companyname.productname.controller.XY` – Marc Nov 23 '15 at 08:11
  • @Bernard im aware of this but i had to mask the company + controllername – deterministicFail Nov 23 '15 at 08:33
  • Have you already tried this for your sorter: `"sorter" : new sap.ui.model.Sorter("SupplierName", false,true);` Here is the API documentation for it [sap.ui.model.Sorter](https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.Sorter.html#constructor) – Christoph Nov 23 '15 at 21:54
  • @Christoph thx for your suggestion, but unfortunaly you cant use the constructor directly in JSON/XML Views – deterministicFail Nov 24 '15 at 07:41

1 Answers1

8

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.

B. Kemmer
  • 1,517
  • 1
  • 14
  • 32