on 08-23-2016 10:09 AM
Hy,
I'am new in the fiori business and i'am struggling with the binding principles.
I created a combox in my XML view with a binding to my odata that has bin loaded by my WEBIDE. I get my list in my dropdown. So far so good but i want to refresh my list after an action by calling the backend again with a parameter. I get a return with different data, but i don't succeed in binding those new items to my drop down. I scanned in my opinion the hole internet but can't find a proper solution.
XML ( view1.xml ) :
<Combobox
id = "expenseID"
items = "{/ExpenseTypes}"
<core:Item key = "{ExpenseTypeID}" tekst = "{Description}"/>
<Combobox>
JS :
sap.ui.controller("view.view1",{
changeExpenseTypes: function(e) {
var model = this.getView().getModel();
var sUrl = "/ExpenseTypes?search=2";
model.read(sUrl, null, null, false, function(data, reponse) {
console.log('success');
console.log(data);
return data; });
}
});
When i call method changeExpenseTypes , i load my allready know model, calling my odata service ExpenseTypes , got a return of 5 new records and then i don't know what to do next to see those new records in my drop down.
Thanks in advance for your help or suggestions !!
Greetings
Jonas
Hi Jonas,
After fetching the new records,
You need to set the model to the drop down again.
Thanks,
Deepak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Problem there is when i’m in the success area that my view isn't know anymore. I can’t load my dropdown for setting values for example.
I would expect that i have to push my values to my model, and the rest would follow like changes in my dropdown.
I tried sap.ui.getCore().setModel(model); in success area also.
You can bind "this" (your controller) to the success callback, see sample code below,
changeExpensesTypes: function(e){
// your code
oModel.read(sUrl, null, null, false, function(data,response){
// this = your view controller
var sId = this.getView().byId("expenseID");
}.bind(this), function(oError){
});
// your code
}
Hi Jonas,
According to your code:
Hope now you will get the sol
Thanks,
Deepak.
Hy Deepak,
Thanks for all the effort, it works know ! I'm happy ...
Reason why i chosen the path /ExpenseTypes is because it is the name of my odata service and with the first run he went directly to the backend for his data. But one off the problems was that my model had an other definition and couldn’t find the new data. ( This is my conclusion )
Greetings Jonas
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.