on 06-23-2016 6:22 AM
Hi, As per the API documentation, oData remove method success callback function should send an argument oData, but its coming as undefined and also can you please help me with "is it possible to pass additional arguments to callback function"?
deleteProduct:function(oEvent){
var sPath=oEvent.getSource().getBindingContext().getPath();
this.getModel().remove(sPath, {
context:sPath,
success:this._onDelSucc.bind(this),
error:this._onDelFail.bind(this)
}
);
},
_onDelSucc:function(oData,response){
//OData object value is coming as undefined.
//MessageToast.show("product "+response.requestUri.split("('")[1].replace("')","")+" deleted " );
},
_onDelFail:function( ){
MessageToast.show("product can't be deleted " );
}
Thanks.
passing message as an additional argument is worked.
Still not able to figure out why oData argument is coming as undefined.
deleteProduct:function(oEvent){
var prodId = oEvent.getSource().getBindingContext().getProperty("ProductID");
var prodName = oEvent.getSource().getBindingContext().getProperty("Name");
var sMsg ="Product "+ prodId+"("+ prodName +") deleted";
var sPath=oEvent.getSource().getBindingContext().getPath();
this.getModel().remove(sPath,
{context:sPath, success:this._onDelSucc.bind(this,sMsg),error:this._onDelFail.bind(this)}
);
},
_onDelSucc:function(sMsg,oData,response){
MessageToast.show(sMsg);
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the deleteProduct(oEvent) function you can retrieve the product id from the oEvent parameter and store it in a variable. Then in the success callback function you can use this variable to display which product was deleted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Saurubh,
I can do that, my question is why the oData argument in success call back is coming as undefined.
and also I can only use local variable to inline execution of callback, but if the function is outside the delete product closure like code pasted, I must use global which I don't want.
Regards,
Nagaraju
Hi NagaRaju,
please check the remove method in the below piece of code:
oModel.remove('/Products(1)', null,
function()
{
alert("Delete successful");
},
function()
{
alert("Delete failed");
}
);
in the function() you can pass the parameters.
for the brief info please click the below link:
UI Development Toolkit for HTML5 (SAPUI5) - SAP Library
You will some more info regarding this.
Thanks,
Deepak Raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.