Srikanth Kshatriy
Srikanth Kshatriy

Reputation: 444

Sapui5: How to bind oData service to a SAPUI5 table when it has $expand parameter

How to bind oData service to a SAPUI5 table when it uses an OData $expand parameter

<Table id="contactPickerTable"
          items="{path: 'modelPersons>/ContactSet',
          filters : [{path : 'Customer',operator : 'EQ',value1:'2035235403'}]
          parameters : {expand:'Address'}}"  
>
.....
<ObjectIdentifier 
      title="{modelPersons>Title}"
      text="{modelPersons>PersonId}" />

I know the above example of list binding data to a table works. But if there is $expand in my service then how can I display properties of the returned collection in ObjectIdentifier? I mean what will be context path?

Server response looks like this:

<entry>
<id></id>
<title type="text">PartnerSet('2010002791')</title>
<updated>2014-05-24T08:05:58Z</updated>
...
<link href="PartnerSet('2010002791')" rel="self" title="Partner"/>
<link href="PartnerSet('2010002791')/Address" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Address" type="application/atom+xml;type=feed" title="Address">
<m:inline>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" >
<id>PartnerSet('2010002791')/Address</id>
<title type="text">AddressSet</title>
<updated>2014-05-24T08:05:58Z</updated>
<author>
<name/>
</author>
<link href="PartnerSet('2010002791')/Address" rel="self" title="AddressSet"/>
<entry>
<id></id>
<title type="text">AddressSet('')</title>
<updated>2014-05-24T08:05:58Z</updated>
...
<d:FirstName>DM LABO SARL</d:FirstName>
<d:Name>DIDIER MARTIN LABORATOIRE</d:Name>
<d:Name3/>
...
...

How can I access the 'Name' property?

Upvotes: 3

Views: 15446

Answers (1)

Jasper_07
Jasper_07

Reputation: 2473

Try something like below, I assumed that the address had a Street,State and Country, I put them in the a $Select condition to restrict the fields returned

<Table id="contactPickerTable"
       items="{
         path: 'modelPersons>/ContactSet',
         filters : [{ path: 'Customer', operator: 'EQ', value1: '2035235403' }]
         parameters: {
           expand: 'Address',
           select: 'Title,PersonId,Address/Street,Address/State,Address/Country'
         } 
       }">
...
<ObjectIdentifier
     title="{modelPersons>Title}"
     text="{modelPersons>PersonId}" />
     <Text
        text="{modelPersons>Address/Street}"/>
     <Text
        text="{modelPersons>Address/State}"/>
     <Text
        text="{modelPersons>Address/Country}"/>

JsBin Example: OData Expand and Select with XmlView

Upvotes: 2

Related Questions