on 2016 Jul 07 4:05 PM
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
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.