Skip to Content

Table is not refreshing after deleting item

Jul 17, 2017 at 10:17 AM


avatar image
Former Member


I am creating a table with delete option with OData model, after clicking on the delete button, updated table is not rendering. Please check attached image for UI and please check below delete button code.

handleDelete: function(oEvent) {
oModel.remove(sPath, {
	success: function(oEvent) {"Employee deleted Successfully");
	error: function() {"Failed to delete");
var oModel1 = new ODataModel("/sap/opu/odata/sap/ZEMPLOYEEPROJ_309_SRV/");
var oMod = new sap.ui.model.json.JSONModel();
oMod.loadData("/sap/opu/odata/sap/ZEMPLOYEEPROJ_309_SRV/ZEMPLOYEE309Set?$format=json", null, false, "GET", false, false, null);
sap.ui.getCore().setModel(oMod, "employee");

When I refresh browser I can able to see the table with latest binding so please say how to resolve my issue.

Sai Ram Dinesh Pallapotu

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Sharath M G Jul 17, 2017 at 10:55 AM

Use the method "refresh" on the model. It should refresh the data in the model.

// Remove the entry from the model
// then refresh the model
// Note: If the model is bound to the table then the contents in the table should get refreshed. 

in the delete method, just remove the entry from the model and trigger the refresh and test it. It should reload the data to the boudn controls(which is the table in your case).



Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sharath,

Thanks for your suggestion now the app is working fine.

Sai Ram Dinesh Pallapotu


Anytime. Welcome.

Akhilesh Upadhyay Jul 18, 2017 at 12:01 PM

oModel.refresh() inside success function should work, or just place your refresh (loaddata) code inside success function.

10 |10000 characters needed characters left characters exceeded
Ashwin Narayan Jul 18, 2017 at 11:19 AM

Hi Sai Ram,

Ideally using model.refresh(), it should refresh the model and the controls bound to it. But there could be scenario wherein it takes time to update and you might need to show in the table that the deleted record doesn't exist. In this scenario we can use splice.

Steps to achieve this:

  1. Get the table instance in controller
  2. Get the model instance which is bound to the table.
  3. Get a unique value within the record which is to be deleted.

Assuming the one of the key field is a Meter Number which is to be deleted.

for(var i=0;i<MODEL_INSTANCE.METERDATA.length;i++) {

var modelMeterNo=MODEL_INSTANCE.METERDATA[i].Meterno;

if(modelMeterNo==Meter Number Which is selected for deletion) {



Hope it should work !!!



10 |10000 characters needed characters left characters exceeded