on 10-05-2017 4:30 PM
Hi,
I am new to UI5 and after having searched a lot, I cant find a solution to bind the oData service to a select element in my code. The requirement is to get the input from the first drop-down to filter second drop-down. The first dropdown workd perfectly fine.
The second dropdown seems to not bind the items to the element.
First Dropdown view.xml
Second dropdown view.xml
controller.js (first approach)
Second approach
I am not sure what am I missing here but both the approach doesn't work. Could you please let me know what is missing?
Regards
Sai
Hi,
This is now fixed. I used the following approach and it worked
this.getView().byId("idSIssSubCat").setModel(this.oIssueCategoryModel);
var oItemSelectTemplate = new sap.ui.core.Item({ key : "{ProdCategory}:"+"{Subcategory}", text : "{Description}" }); this._oView.byId("idSIssSubCat").bindAggregation("items","/results",oItemSelectTemplate);
var sServiceUrl = this._oComponent.getMetadata().getConfig().serviceConfig.serviceUrl;
var oConfig = {
metadataUrlParams: {},
json: true,
// loadMetadataAsync : true,
defaultBindingMode: "TwoWay",
defaultCountMode: "Inline",
useBatch: false
};
this.oDataModel = new sap.ui.model.odata.ODataModel(sServiceUrl, oConfig);
var that = this;
var uri = "/IssueSubCategorySet?$filter=ProdCategory eq '" + oEvent.getSource().getSelectedItem().getKey() + "'";
this.oDataModel.read(uri,
{ success : function(oData)
{ that.oIssueCategoryModel.setData(oData);
sap.m.MessageToast.show("Success!");
},
error : function(oError)
{
zmclaren.prd.util.messages.showErrorMessage(oError);
},
async : false
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Consider your select is in the fragment :
<Select change="selectChange" showSecondaryValues="true">
</Select>
Now from your controller you can bind the model values like this:
var mModel = new sap.ui.model.json.JSONModel(); //initialise your model from a JSON file
this._model.read("/UserSet",null,null,false,function(oData){
mModel.setData(oData);
},function(){
});
var oItemSelectTemplate = new sap.ui.core.Item({
key : "{Userid}",
text : "{Userid}"
}); //Define the template for items, which will be inserted inside a select element
var mySelectMenu = this.oDialogFragment.getContent()[0].getContent()[2]; //Get a reference to the UI element, Select to bind data
mySelectMenu.setModel(mModel);// set model your_data_model to Select element
mySelectMenu.bindAggregation("items","/results",oItemSelectTemplate); //bind aggregation, item to Select element with the template selected above
Hope this helps,
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi There,
In your first approach, change the code to:
subCatIss.bindItems({
path:"/IssueSubCategorySet",
filters:[new sap.ui.model.filter.Filter({path:'ProdCategory',operator:'EQ',value1:oEvent.getSource().getSelectedKey()],
template:oItemSelectTemplate
});<br>
This should correctly encode the service URL and should work. bindAggregation should also work if you use filters array in binding and not appending "$filter" directly to URL.
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 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.