Skip to Content
0

Dynamically add rows and delete rows in sap.m table

Mar 28 at 04:06 AM

54

avatar image

I am new to SAPUI5. I have created a Simple form. After submitting the form the details must get added in table dynamically and can also be deleted.While delete operation it shows the error "Cannot read property 'getData' of undefined".

Following is the function of delete.

"delete": function(e)

{

var path = e.getParameter('listItem').getBindingContext("mainModel").getPath();

var idx = parseInt(path.substring(path.lastIndexOf('/') +1));

var oModel = this.getModel();

var oData = oModel.getData();

var removed = oModel.results.splice(idx, 1);

oModel.setData(oData);

}

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

3 Answers

MERCY ANGELIN V Mar 28 at 10:07 AM
0

I found out the mistake

"delete": function(e)

{

var path = e.getParameter('listItem').getBindingContext("mainModel").getPath();

var idx = parseInt(path.substring(path.lastIndexOf('/') +1));

var oModel = this.getModel("mainModel");

var oData = oModel.getData("mainModel");

var removed = oData.results.splice(idx, 1);

oModel.setData(oData);

}

Thanks Drushya & Tri

Share
10 |10000 characters needed characters left characters exceeded
Drushya S Mar 28 at 04:59 AM
0

check whether you are getting the model in this way.

var oModel = this.getModel("mainModel");

Share
10 |10000 characters needed characters left characters exceeded
Tri Minh Le Mar 28 at 04:47 AM
0

Hi Mercy,

I see that you have 2 models: mainModel and "undefined" model. Which one you want to delete records from?

Regards,

Tri

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I want to delete from mainModel.

0