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
831

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
saivellanki
Active Contributor
0 Kudos

Hi La,

The more appropriate way to handle this type of scenario is using parts binding.

I have used the same JSON model, here is a Sample: JS Bin - AttributesPartsBinding


If you think that 'Parameters' object keys are dynamic and you're not aware of what might come in future, then you will have to manually add them, here is a sample where attributes are created manually: JS Bin - AttributesManualCreate

Regards,

Sai.

Tula
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sai,

Great!!! Thank you very much The second one is really what I want to achieve.

Regards,

La