Skip to Content
0

Fetching data from ODATA model to SAPUI5 webpage with different controls and

Jan 26 at 08:50 AM

87

avatar image
Former Member

Hi SAPUI5/ODATA Experts,

I have a SAPUI5 page developed in view.js and controller.js with having mutliple combobox controls in the SPAUI5 page.

Can anyone suggest,on how to get data for that particular combobox using odata model,i don't want any JSON included in between and i don't want to use view.xml in SAPUI5.

Please help me with some sample links or codes

Please help me soon !!

Thanks,
Jay

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Efim Parshin Jan 26 at 09:16 AM
0

Hi! If you have oData entity sets that represent data for paticular combobox, you can directly bind it to ODataModel:

//You have default ODataModel with entity set ComboBoxData1 that contains set of key-value pairs
new sap.m.ComboBox({
items:{ path: '/ComboBoxData1', template: new sap.ui.core.Item({ key: '{keyProp}', text: '{textProp}'
})
}
})
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 26 at 09:29 AM
0

Hi Efim,

Firstly thanks for the reply !!

pls find my code below and correct em if i am wrong,as this is my first project in SAPUI5

View.js :

var oComboBox_FunArea = new sap.ui.commons.ComboBox("FunArea",{Items:{path:"/sServiceUrl"}});

controller.js:

onInit: function() {

var sServiceUrl = ("proxy/http/____________:8000/sap/opu/odata/SAP/YREQSUB2_SRV/");

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,true);

this.getView().setModel(oModel);

}

or else please help me with more detail elaboration of code.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Its looks ok, except for ComboBox items binding.

1) You should find entitySet that represent data for you combobox items (navigate to your service url to find). You should bind items to entity set, not service name.

Or it can be relative binding through navigation property from specific entity, but i'm suppose this is not your case.

2) Set template for each item of this set as i shown above.

0
avatar image
Former Member Jan 29 at 11:10 AM
0

Hi Efam,

Thanks for the reply,i did the same way as you said.

I have tired the way,but if i maintain the KEY and Text field values as blank,the i am getting list as [object Object] or else if fill any values in the KEY and Text field,i am getting the combo box as empty list as shown in the attached image,whereas here the count of empty list is same as columns in the Tables.

View.js:

var oComboBox_FunArea = new sap.m.ComboBox({ items:{ path: "/XYZSet", template : new sap.ui.core.Item({ key:'{ABC}', text:'{ABC}' }) };

Controller.js:

var sServiceUrl = ("proxy/http/____________:8000/sap/opu/odata/SAP/YREQSUB_SRV/");

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,true);

this.getView().setModel(oModel);

sap.ui.getCore().setModel(oModel);

Can you please advise me,what does the KEY field in sap.core.item exactly required for and can i

maintain the same values in KEY and Text fields.


empty-list.png (1.5 kB)
object-list.png (69.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 29 at 01:40 PM
0

Hi Efam/SAPUI5 Experts,

Can please help me on this ASAP.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 29 at 01:40 PM
0

Hi Efam/SAPUI5 Experts,

Can please help me on this ASAP.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 29 at 01:40 PM
0

Hi Efam/SAPUI5 Experts,

Can please help me on this ASAP.

Share
10 |10000 characters needed characters left characters exceeded