Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 13, 2017 at 09:08 AM

    Hi Janani ,

    Please check whether Table object is returned correctly .

    Also just keep a debugger and check if there is any data "data" array if this is not so then you need to check the binding of table .

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2017 at 12:36 PM

    make sure the data is array....

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 11, 2017 at 02:40 AM

    what path does you bind the rows to?

    -D

    Add comment
    10|10000 characters needed characters exceeded