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

Binding Path for nested array in SAPUI5 Table

0 Likes
4,391

I am trying to bind a nested array to the SAPUI5 table.

Json Model:
{
"Departments": [
    {
        "ID": "1",
        "Name": "Oil and Gas",
        "Employees": [
            {
                "ID": "12345",
                "LastName": "Tom"
            },
            {
                "ID": "678",
                "LastName": "Jerry",
            }
        ]
    },
    {
        "ID": "2",
        "Name": "Gasoline",
        "Employees": [
            {
                "ID": "21",
                "LastName": "Donald"
            },
            {
                "ID": "22",
                "LastName": "duck"
            }
        ]
    }
]
}

I am using SAPUI5 table:

 <Table 
    items="{path:'oDataItem>/Departments/Employees'}"                                       
    width="auto"
    fixedLayout="false" 
    mode="MultiSelect" >
    <columns>
        <Column width="auto">
            <Text text="LastName of Employee" />
        </Column>
     </columns>
         <items>
             <ColumnListItem>
                 <cells>
                      <Input editable="true" textAlign="Left" type="Text" change="onNameTextChange" width="15em" value="{path:'oDataItem>LastName'}" />
                 </cells>
            </ColumnListItem>
         </items>           
 </Table>

Above databinding path is not returning any data. 
Can i fetch lastName by XML databinding? If yes, than how i fetch last name?

Thanks 
View Entire Topic
junwu
SAP Champion
SAP Champion
0 Likes
    items="{path:'oDataItem>/Departments/0/Employees'}"  
you can change to other index value. I didn't try in my system, hopefully it works.
0 Likes

@Jun Wu : Ur solution always provide index 0. It is not dynamic. I did some research, i came to conclusion that data binding in XML wont help in my scenario. I need to build my own json and bind it

maheshpalavalli
Active Contributor
0 Likes
gopalp, yes you need to manipulate the data and build your structure for your scenario