odatasapui5

Binding Item data to the Detail View


This is my View Page

SecondView.view.xml

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form" xmlns:anubhav="myfiori.controls" xmlns:html="http://www.w3.org/1999/xhtml" controllerName="myfiori.controller.SecondView">
<Page title="My Second View" showNavButton="true" navButtonPress="onBack" content="{/ZPO_HEADERSet}">
    <content>

        <Table id="lineItemsList" width="auto" items="{toItems}">
            <headerToolbar>
                <Toolbar id="lineItemsToolbar">
                    <Title id="lineItemsHeader" />
                </Toolbar>
            </headerToolbar>
            <columns>
                <Column>
                    <Text text="Doc No" />
                </Column>
                <Column >
                    <Text text="Material No"/>
                </Column>
            </columns>
            <items>
            <ColumnListItem >
                    <cells>
                        <Text text="{Ebelp}"/>
                        <Text text="{Matnr}"/>
                    </cells>
                </ColumnListItem>
            </items>
        </Table>
    </content>

</Page>

My Item data path is "ZPO_HEADERSet('1100000001’)".so that I will get all the Items for the particular Header Id.

My controller

SecondView.controller.js

 sPath = "/ZPO_HEADERSet('" + Id + "')";
 this.getView().bindElement(sPath);

On pressing the Master Row, I should get it's items. But I'm getting all Item rows of every Header Id as shown in below screenshot.

enter image description here


Solution

  • This is because in your Page you are binding the whole entity set to the content aggregation.

    Delete this content="{/ZPO_HEADERSet}" and try again.

    The bindElement(sPath) function will prefix all your relative bindings with the 'sPath'