on 07-01-2015 1:39 PM
Hi,
I have a view in xml.
In my view, I insert 2 combobox :
<Combobox id="combo1"
selectionChange = "onComboSel"
items="{
path: '/CountryF4Set',
filters: [{ path: 'ZCOMBO', operator: 'EQ', value1: '1' }]
}"
<items>
<core:ListItem text="{ZTEXT}" key="{ZKEY}"> </core:ListItem>
</items>
</Combobox>
<Combobox id="combo2"
selectionChange = "onComboSel"
enable='false'>
<items>
<core:ListItem text="{ZTEXT}" key="{ZKEY}"> </core:ListItem>
</items>
</Combobox>
I want to know how add add value (retrieve from backend with path and filter) in my combo2 in function onComboSet ?
=> I want to translate :
items="{
path: '/CountryF4Set',
filters: [{ path: 'ZCOMBO', operator: 'EQ', value1: '1' }]
}"
in javascript !
Thanks for your help
Hi Adeline Louise,
1. First create oDATA Class to fetch data from server to client side.
for ex:
new sap.ui.model.odata.ODataModel("
/sap/opu/odata/SAP/ZNASS_MYTEAM_SRV");
var model = new sap.ui.model.odata.ODataModel(serviceURL, true);//ZODATA_SRV_SPB_GWS
var readRequestURL = oEvent.requestURL;
model.read(readRequestURL, null, null, false,
function(oData, oResponse) {
oDataModel = oData.d.results;
///////Simulation EXample
create read request to get record. inside success block, you might get this JSON format.
var oDataModel = {"d":{"results":[{"__metadata":{"id":"http://w.corp:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793811')","uri":"http://w:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793811')","type":"ZODATA_SRV_SPB_GWS.CHN_SCType"},"ID":"160405691834793811","CA_STATUS_RAG":"A","CM_COUNT":"10"},{"__metadata":{"id":"http://w.corp:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793812')","uri":"http://w.corp:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793812')","type":"ZODATA_SRV_SPB_GWS.CHN_SCType"},"ID":"160405691834793812","CA_STATUS_RAG":"G","CM_COUNT":"23"},{"__metadata":{"id":"http://w.corp:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793813')","uri":"http://w:8015/sap/opu/odata/sap/ZODATA_SRV_SPB_GWS/CHN_SC('160405691834793813')","type":"ZODATA_SRV_SPB_GWS.CHN_SCType"},"ID":"160405691834793813","CA_STATUS_RAG":"R","CM_COUNT":"1"}]
}}
});
2. Get this JSON record and put it into one variable. ( var oDataModel )
3. var components = new sap.ui.model.json.JSONModel(oDataModel );
sap.ui.getCore().setModel(components);
4. create one dropdown
var oItemTemplate = new sap.ui.core.Item({
key: "{CA_STATUS_RAG}",
text: "{CM_COUNT}"
});
var oComboBox = new sap.m.ComboBox({
items: {
path: "/d/results",
template: oItemTemplate,
},
});
Thanks,
Karthik A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this.byId("combo1").bindAggregation("items",{
path: '/CountryF4Set',
filters : [
new sap.ui.model.Filter('ZCOMBO', sap.ui.model.FilterOperator.EQ, '1')
]});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.