Hi,
I need to update binding after CRUDQ operation on oData service. In my code i have deleted one of the card details which gives success message but page does not display the updated binding unless page refreshed manually. Can someone please advice so page does not display the deleted card as soon as it got deleted.
I have called refresh() in the code like below but it still does not show the updated binding.
else if (this.mode == 'DeleteCard'){
var oModel3 = sap.ui.getCore().byId("CardRBG").getModel("CardModel");
// Index of selected radio item
var oIndex = sap.ui.getCore().getControl("CardRBG").getSelectedIndex();
if(oIndex == -1){sap.ui.commons.MessageBox.alert("Please select a card to delete")};
// Read result
var oResults = oModel3.getProperty("/");
var oUCRN = oResults[oIndex].UCRN;
var oBusPartner = oResults[oIndex].BusPartner;
var oCardKey = oResults[oIndex].Card_Key;
var oCardMask = oResults[oIndex].Card_Mask_num;
var requrl = "/sap/opu/odata/SAP/Service/PaymentCardSet(UCRN='"+oUCRN+"',Card_Key='" + encodeURIComponent(oCardKey) + "',Card_Mask_num='"+ encodeURIComponent(oCardMask).replace(/\*/g,"%2A") + "')";
OData.request({requestUri: requrl , method: "GET", headers:{"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json",
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0",
// "Accept": "application/json",
"X-CSRF-Token":"Fetch"}},function(data, response){
var header_xcsrf_token = response.headers['x-csrf-token'];
console.log(header_xcsrf_token);
var url = "/sap/opu/odata/SAP/service/PaymentCardSet(UCRN='"+oUCRN+"',Card_Key='" + encodeURIComponent(oCardKey) + "',Card_Mask_num='"+ encodeURIComponent(oCardMask).replace(/\*/g,"%2A") + "')";
var method = "DELETE";
requestObj.requestUri = url;
requestObj.method = method;
requestObj.headers = {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json",
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0",
//"Accept": "application/json",
"X-CSRF-Token": header_xcsrf_token};
OData.request(requestObj, function(data, request){
sap.ui.getCore().byId("CardRBG").getModel("CardModel").refresh();
sap.ui.getCore().byId("CardRBG").getModel("CardModel").updateBindings();
sap.ui.commons.MessageBox.show("Card Sucessfully Deleted", null, "Success", 'OK' );
//alert("Card Sucessfully Deleted");
},function(err){
sap.ui.commons.MessageBox.alert("Failed to delete selected card");
}