cancel
Showing results for 
Search instead for 
Did you mean: 

Bind sap.m.select to a table rows

jatinder_jaswal
Explorer
0 Kudos
153

Hi All,

I am a SAPUI5 newbie and facing some issues with my first Fiori App. I want to bind a sap.m.select control to a table from our backend system. Lets say that I have binded the current view to a "Trip" model and now if I want to bind a sap.m.select control to "Countries" table from backend how can i do that. How can i show values from country table in a sap.m.select control used in XML views. I have already tried the below code but the select control is coming as blank with no item in items aggregation.

<Select xmlns:sap.ui.core="sap.ui.core" selectedItem="Element sap.ui.core.ListItem#__item3"

                    selectedKey="item1" selectedItemId="__item3" id="lstDestination"

                    items="{path: 'CountryCollection'}">

                           

    <sap.ui.core:Item key="{LAND1}" text="{INTCA3}" />   

                       

</Select>

Thanks a lot.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member225463
Participant
0 Kudos

Hello Jatinder,

Try using items="{path: '/CountryCollection'}"> and check in the network tab that an oData Call is going to the backend or not?


Regards,

Vikash

jatinder_jaswal
Explorer
0 Kudos

Hi Vikash,

Thanks for replying. However items="{path: '/CountryCollection'}" attribute is already mentioned. And when checked i found that no request is being sent for fetching CountryCollection. I have already set the model for the view, which is "TripCollection", where can i set the model for select control so that it sends a request to fetch countrycollection.

former_member225463
Participant
0 Kudos

Hello Jatinder,

Standard wise you should declare your models in the Component.Js file so it becomes global and all the views and controllers of the application can use it.

Regards,

Vikash

saurabh_vakil
Active Contributor
0 Kudos

You could check this example - http://jsbin.com/hakizo/5/edit?js,output

jatinder_jaswal
Explorer
0 Kudos

Hi Saurabh,

Thanks a lot for replying. However as me being a newbie can you suggest some example where select is directly linked to table data instead of JSON data. As of now my XML data is as below

<feed xml:base="http://192.168.0.155:8000/sap/opu/odata/sap/ZTNE_SRV/">

<id>

</id>

<title type="text">CountryCollection</title>

<updated>2016-04-11T13:39:01Z</updated>

<author>

<name/>

</author>

<link href= "CountryCollection" rel="self" title="CountryCollection"/>

<entry>

<id>

</id>

<title type="text">CountryCollection('')</title>

<updated>2016-04-11T13:39:01Z</updated>

<category term="ZTNE_SRV.Country" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link href= "CountryCollection('')" rel="edit" title="Country"/>

<content type="application/xml">

<m:properties>
<d:Intca3/>

<d:Intca>AN</d:Intca>

<d:Land1>AD</d:Land1>

<d:Mandt/>

</m:properties>
</content>

</entry>