on 01-29-2018 2:19 PM
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.
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: "/EntitySet_Name", template : new sap.ui.core.Item({ key:'{Table_Field_column_name}', text:'{value of the field}' }) };
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.
Please help me soon !!
Hello Vijay,
Yes you can give the same value for key an text, one of the use for key is for validation, if user enters any value in combo box, we can validate the value using key property.
Can you try the below code once?
this._oView = this.getView();
var OModel = this._oView.getModel("dataset");
sap.ui.getCore().setModel(OModel); //the model defined in manifesto
sap.ui.getCore().byId("combo").setModel(OModel);
var oItemTemplate1 = new sap.ui.core.ListItem();
oItemTemplate1.bindProperty("text", "Desg");
oItemTemplate1.bindProperty("key", "Desg");
sap.ui.getCore().byId("combo").bindItems("/DesignationSet", oItemTemplate1); //reference to the entityset
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
oCombo = new sap.m.ComboBox({filterSecondaryValues: "true", showSecondaryValues:"true", enabled:"{state>/comboPreventive}", width:"100%"});
oListItem = new sap.ui.core.ListItem({key:"{plantuser>EmployeeId}",text:"{plantuser>EmployeeName}"});
oCombo.bindItems("plantuser>/d/results",oListItem);
Regards,
Nagarajan S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
why you are so against json model and xml view?
js view should always be your second option.....
{Table_Field_column_name} is it a field under the entity?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello again! Why do you use deprecated version of ODataModel? Use sap.ui.model.odata.v2.ODataModel instead. And settig model to Core it's bad practice. Setting model on view will be enough.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Share your view code and network screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.