Skip to Content
0

Access complex JSON model with a model identifier

Oct 26, 2016 at 04:22 AM

27

avatar image

Hello Experts,

i have a JSON model like the following.


{
"EmployeeID": 1,
"LastName": "Davolio",
"FirstName": "Nancy",
"Address": "507 - 20th Ave. E. Apt. 2A",
"City": "Seattle",
"Region": "WA",
"PostalCode": "98122",
"Country": "USA",
"HomePhone": "(206) 555-9857",
"ResumeID": 1,
"Resume" : {
"Information": "Information of Nancy Davolio",
"Projects": "Projects of Nancy Davolio",
"Hobbies": "Hobbies of Nancy Davolio",
"Notes": "Notes of Nancy Davolio"
}

}

i have loaded through the manifest file with an identifier "Employees". So now this should a named model.

i am trying to bind it to a list as follows.

<List
id="resumelistID"
items="{EmployeesEXT>Resume}"
headerText="Employee Resume">
<items>
<StandardListItem
title="{Information}"
description="{Resume>Projects}"
type="Navigation"
press="onResumeListPressEH">
</StandardListItem>
</items>
</List>

Resume is accessible with {EmployeesEXT>Resume}. But somehow i failed to bind values which inside "Resume" (Information, Projects, Hobbies,Notes).

i tried many combinations, like

{EmployeesEXT>Resume>Information},

{EmployeesEXT>Resume/Information}

{Resume>Information}

{Information}

i am really confused how to bind the resume data in the list.

i tried printing bindingContext in console. I got the perfect result. Resume data is bound to the list with sPath "0/Employees/Resume/Information". Somehow i am unable to display the values in the list.

Can anybody help me resolving my issue.

Thanks in advance for the help.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Krishna Kishor Kammaje
Oct 27, 2016 at 04:01 AM
0
items="{EmployeesEXT>Resume}"

Above statement is wrong. This is because Resume is not an aggreagation/array.

Change json model like this.

"Resume" : [{"Information": "Information of Nancy Davolio","Projects": "Projects of Nancy Davolio","Hobbies": "Hobbies of Nancy Davolio","Notes": "Notes of Nancy Davolio"}]

And then

<StandardListItem title="{EmployeesEXT>Information}"description="{EmployeesEXT>Projects}"type="Navigation"press="onResumeListPressEH"> </StandardListItem>
Share
10 |10000 characters needed characters left characters exceeded