Skip to Content

Refreshing model after Odata.remove not working

Once I delete a record, I am trying to refresh my model so the table to which the model is bound shows latest set of records...which is not working though. May I know how we can refresh the model after delete method is invoked. Or, the only way to show latest records (post deletion) in the table is to again call a READ method and get the records from the back-end ?

var oTab = sap.ui.core.Fragment.byId("DOCSUPLOAD", "idTab").getModel("docsList");

var oDataMdl = this.getOwnerComponent().getModel();

oDataMdl.remove("/<EntitySet>(keycolumn='Value_1', keycolumn2='key2')", 
{ 

success: function(oData, oResponse){

sap.ui.core.Fragment.byId("DOCSUPLOAD", "idTab").getModel("docsList").refresh();

MessageBox.show("Success");

}.bind(this),

error: function(oError){
	MessageBox.show("Failed");
}					
}
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 15, 2019 at 08:53 AM

    Hi Venkata,

    Which ODataModel are you using?

    ODataModel version 2 automatically refreshes the bindings that depend on changed entities.

    Please see screenshot below with the relevant details mentioned in SDK.

    Do let me know in case you are still facing the issue.

    Regards,

    Rohit


    ss1.jpg (77.5 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 15, 2019 at 05:11 AM

    Hi Venkata,

    Can you set the refreshAfterChange parameter to true while calling remove method of OData model.

    https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/remove

    Regards,

    Karan Shaheri.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.