on 11-02-2017 3:21 PM
Hi, I'm a UI5 newbie so go easy one me 🙂
a question about filtering, I have 2 select boxes in my view, the first select box is the 'parent' and it's key is also a key of the second 'child' select box... each is bound to a different entity from my data model, see below
I need to filter the values of the second select box based on the selected value of the first.
So i have defined a function for the change event of the first select box. But I'm not sure how the function should work exactly, this is what I have so far... it clearly doesn't work.
onChange: function(evt) {
var selectedProject = this.getView().byId("projectSelectBox").getSelectedKey();
var filterByProject = new sap.ui.model.Filter("ProjectInternalId",sap.ui.model.FilterOperator.EQ,selectedProject);
var changeRequest = this.getView().byId("changeReqSelectBox");
changeRequest.bindAggregation("items",filterByProject);
}
Am I even close...?
Many thanks for answering Arjun, I'll try this out today.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Neil Ward,
Even as a newbie, you have done good work. To populate data in your second select box, based on your first select box, you need to first get the selected data , then filter your model and populate the recieved records in your second select box.
/**
* When the combo box is changed in a fragment.
* @public
*/
selectChange: function(evt){
evt.getSource().setValueState(sap.ui.core.ValueState.Success);
var that = this;
var mModel = new sap.ui.model.json.JSONModel(); //initialise your model from a JSON file
var id = this.oDialogFragment.getContent()[9].getSelectedItem().getText();
//get the id first, then read the other model, you can even filter it.
this.model.read("/UserSet('"+id+"')",null,null,false,function(oData){
mModel.setData(oData);
},function(){
});
var oItemSelectTemplate = new sap.ui.core.ListItem({
key : "{Userid}",
text : "{Userid}",
additionalText: "{Username}"
}); //Define the template for items, which will be inserted inside a select element
var mySelectMenu = this.oDialogFragment.getContent()[9]; //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
},
Read your model, then set the data to an template for your select, then you can set the model and perform bind aggregration.
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.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.