Skip to Content

Binding Path for nested array in SAPUI5 Table

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 
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jun 19, 2020 at 01:23 PM

    > /Departments/Employees

    Which list of employees should the table pick from the departments list? The table cannot know.

    The users, however, know which employees from which departments they want to see. Let them decide by allowing them to pick a department first, and then you can bind the corresponding employee list to the table.

    I.e. either a tree-like control or a set of two list controls (one for departments, one for the employee list) is needed in your case. Here is an example: https://embed.plnkr.co/fVCzodmvWzieh2LH

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 20, 2020 at 03:13 PM

    I think you can use element binding and relative binding, no need to create different model.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 19, 2020 at 12:02 AM
    -2
        items="{path:'oDataItem>/Departments/0/Employees'}"  
    you can change to other index value. I didn't try in my system, hopefully it works.
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.