cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get the binding context of each ObjectListItem under the list aggregation binding? Or how to display complicated JSON Data in a List control?

Tula
Product and Topic Expert
Product and Topic Expert
0 Kudos
827

Hi all,

I have a JSONModel, whose data structure is, for instance, as follows:


{ "Actions":[

    {

      "Name":"MessageBox",

      "Description":"Display a message box",

      "Parameters":{

      "id":"123",

      "message":"hello world",

      "buttons":"default",

      "title":"action messagebox"     

      },

    {

      "Name":"Include",

      "Description":"Includes an external text file. The external text file contains also a list of actions",

      "Parameters":{

      "file":"myFile"

      },

    {

      "Name":"NewFolder",

      "Description":"Create a new folder in the file system",

      "Parameters":{

      "folder":"myFolder"

      }

}

The above JSONModel data is going to be displayed in a list. For the common properties (e.g. Name) , the list is displayed well via aggregation binding. However, when I want to display every property under /Parameters as attributes aggragation of ObjectListItem, I can't find a proper way to do that.

The possible solution I though about is as follows: Getting the binding context for each ObjectListItem and adding attribute aggregation according to each retrieved binding context dynamically. Moreover, in this case, I also have to get the inner loop function of  aggregation binding mechanism so that I can assign different attribute aggregation for each binding context of ObjectListItem. However, I didn't manage to find any proper methods in SAPUI5 API. Therefore, if this way works, can anyone tell me which method I should use to retrieve above information? Or if this is not the proper solution, can anyone tell me how to display this kind of data structure in a list? (It is also fine to user other controls like table, important is to display all these inofrmation)

Thank you very much in advance!

Regards,

La

View Entire Topic
Former Member
0 Kudos

You could do the aggregation binding directly in this case too. Find an abstract implementation

JS Bin - Collaborative JavaScript Debugging


var oItem = new sap.m.ObjectListItem();

var oTemplate = new sap.m.ObjectAttribute({

            text: "{Parameters/title}"

});

oItem.bindAggregation("attributes", "/Actions", oTemplate);

Tula
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sakthivel,

Thank you for your answer. However, I think you misunderstood my issue. The thing is that there are not always (very seldmon) same property names under the parameter. In your case, you inserted "title" to other parameters object. Moreover, I want to show all the properties under Parameters. Therefore, do you have any idea?