cancel
Showing results for 
Search instead for 
Did you mean: 

Remove row from table

former_member209118
Participant
0 Kudos

Hi expert,

I'm new to UI5. My requirement is if I click on delete that particular record will delete from table.

So I written my logic according to that,but I struck at one point. I got the particular objects in array which I need to delete but when I use remove keyword the data is not deleting from table. I  Please check the following code

I used the mode to display delete icon in table

In view:

<Table id="table" items="{/items}" mode="Delete" delete="odelete">

Controller:

odelete : function(oEvent) {

  var context = oEvent.getParameter("listItem")

  .getBindingContext().getPath().split("/")[2];

  var obj = this.getView().byId("table").getModel()

  .getData();

  var item = obj.items[context];

  obj.remove(item);

Thanks,

Ashok.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

HI Ashok

Here is an simple example

-D

former_member209118
Participant
0 Kudos

Hi Dennis,

Thanks for your reply I tried that,but it doesn't work for me.

Thanks,

Ashok.

former_member182862
Active Contributor
0 Kudos

From what I understand, it works in JSBin but it does not work in your code.

What are the difference then?

Thanks

-D

former_member209118
Participant
0 Kudos

Hi Dennis,

When I'm doing that the whole records were deleting from table.

Thanks,

Ashok.

former_member182862
Active Contributor
0 Kudos

Sorry, I am unable to follow you. I initially I was thinking that you want to remove a row from table. But evidently, it is not just that.

-D

former_member209118
Participant
0 Kudos

Hi Dennis,

I got the answer. thanks for your reply. Instead of remove I used splice to remove data and after that I refreshed my model.

code:

data.splice(index, 1);

       this.getView().byId("table").getModel().refresh(true);

Thanks,

Ashok.

Answers (0)