Skip to Content
0
Nov 10, 2017 at 10:28 AM

How to delete a table row using mode="Delete"?

1202 Views Last edit May 26, 2020 at 06:47 PM 3 rev

Hi,

I have created a table and bind json data into it. I have to perform add and delete operations. Add operation works fine. For delete operation, I have used mode="Delete".

For this I have added a function in my controller.

the controller code is

onDelete: function(oEvent) {
			var item = oEvent.getParameter("listItem");
			var path = item.getBindingContext().getPath();
			var idx = parseInt(path.substring(path.lastIndexOf('/') + 1), 10);
			var table = this.getView().byId("idProductsTable");
			var model = table.getModel();
			var data = model.getData();
			data.splice(idx, 1);
			model.setData(data);
		}

I am getting error as ----- data.splice is not a function

By using the below code,

onDelete: function(evt) {  
evt.getSource().removeItem(evt.getParameter("listItem"));
}

I can able to delete the row. But again when i try to add a new entry it's showing error as---- Error: adding element with duplicate id '__text5-__xmlview0--idProductsTable-1'


Please help me with this.

Thanks,

Janani