简体   繁体   中英

How to bind oData model to table in block view of object page layout?

How do i bind the model data from the oData entityset response to the table inside the xml block view? I want to set/bind the model data to table rows in the view 'directly' instead of binding it to table rows in the object page view controller methods via events

   Below code from block view:

    <Table id="sponClassTable" growing="true" growingThreshold="5"
inset="false"
    items="{
        path: '/SponClassSet'
    }">

   Binding to table cells in block view:

            <items>
        <ColumnListItem>
            <cells>
                <Text 
                    text="{sponsModel>SponsoredClass}"/>
                <Text
                    text="{sponsModel>ClassType}" />
                <Text
                    text="{sponsModel>IdcRelevant}" />
                <Text
                    text="{sponsModel>SponsClassDesc}" />
                <Text
                    text="{sponsModel>SpClFromDt}" />       
                <Text
                    text="{sponsModel>SpClDefault}" />                      

            </cells>
        </ColumnListItem>
    </items>
</Table>

You are binding your table to different models.

The table items are bound to an unnamed model path: '/SponClassSet' and your Text cells are bound to a named model called sponsModel text="{sponsModel>SponsoredClass} ? What name are you using for your odata model ? Unnamend or sponsModel ? Search for method setModel in your code or take a look in your manifest.json which name you have chosen for your Odata model. In addition to that take a look in the OpenUi5 documentation how views are bind to data models.

<Table id="sponClassTable" growing="true" growingThreshold="5"
inset="false"
    items="{
        path: '/SponClassSet'
    }">

   Same sub-view, here Binding to table rows:
            <items>
        <ColumnListItem>
            <cells>
                <Text 
                    text="{sponsModel>SponsoredClass}"/>
                <Text
                    text="{sponsModel>ClassType}" />
                <Text
                    text="{sponsModel>IdcRelevant}" />
                <Text
                    text="{sponsModel>SponsClassDesc}" />
                <Text
                    text="{sponsModel>SpClFromDt}" />       
                <Text
                    text="{sponsModel>SpClDefault}" />                      

            </cells>
        </ColumnListItem>
    </items>
</Table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM