on 04-13-2017 1:15 PM
I've a list which is initialized when application starts. I'm performing crud operation. when i'm deleting any item, or adding any item, It doesn't refreshed.
var listRules=that.getView().byId("lstAutomationRules");
listRules.getModel().refresh();
I use above approach to refresh my list. but it doesn't work. the code of list back-end is as below.
<List id="lstAutomationRules" itemPress="onListItemPress" showUnread="true" items="{/d/results}">
<infoToolbar>
<Toolbar visible="false" id="idInfoToolbar">
<Label id="idFilterLabel"/>
</Toolbar>
</infoToolbar>
<items>
<StandardListItem title="{name}" type="Active" description="{description}" custom:to="{id}"/>
</items>
</List>
//prepare url for fetching records.....
var url = sap.samhengi.util.replaceDoubleCurleyBrackets(that.conf.fetchAutomationRules);
$.ajax({
url: url,
method: "GET",
dataType: "json",
headers: {
"Accept": "application/ld-frame+json"
}
}).done(function(data) {
var oModel = new sap.ui.model.json.JSONModel(data);
//binding model...
that.getView().setModel(oModel);
}).fail(function(error) {
reject();
});
});
try below code once:
oList.getModel().updateBindings(true)
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 not using read operation to read the data ? why ajax?
as per my understanding, if you will perform model.read operation and do model.refresh(true), then your model and respective binding should get refreshed with updated data.
And in your current scenario, if you are removing data from model only, then automatically list would be refreshed with updated data (since json model is twoway binding),
if you are deleting data from backend and you wants to refresh list wont work, you need to trigger your backend call again to get he updated data and do what you are doing with ajax.
HI Nafees
I believe that it is due to caching. I may be wrong. try this (cache: false)
$.ajax({
url: url,
method: "GET",
dataType: "json",
cache: false,
headers: {
"Accept": "application/ld-frame+json"
}
Thanks
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
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.