cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh list in sapui5

Former Member
0 Kudos

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();
});
});

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member227918
Active Contributor

try below code once:

oList.getModel().updateBindings(true)

Former Member
0 Kudos

doesn't work

former_member227918
Active Contributor

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.

Former Member
0 Kudos

any example for "model.read operation" ?

former_member182862
Active Contributor
0 Kudos

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