cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot delete line from table with delete button

Karan_Chopra_
Active Participant
0 Kudos

Hello Experts,

I have created a table with delete functionality as per the type delete of table as below.

Unfortunately the delete functionality is not working on clicking the delete button, below is the code I have written in JS base on information I got online.

I am not able to get value in variable oRowData from the method oModel.getData because of which it is not recognize the splice method.

I have searched some site and was able to get this code implementation only to delete row, also I observed the table was created using Java Script as per code online but in my case I have created through layout editor in XML, is the the problem here?

Request you help here..

Will reward accordingly.

Accepted Solutions (0)

Answers (7)

Answers (7)

Karan_Chopra_
Active Participant
0 Kudos

here again it is returning undefined value

not sure where am I missing something

Karan_Chopra_
Active Participant
0 Kudos

I am able to get model but not the data thru getData

junwu
Active Contributor
0 Kudos

if you look at your screen shot, you are not able to get model!!!!!!!!!!!! it is undefined......

junwu
Active Contributor
0 Kudos

from the binding context, you can also get the model

Karan_Chopra_
Active Participant
0 Kudos

The problem is I am not getting data after calling getData method, it returns null

Till getModel methods its working fine

Below is the console output:

Following is table structure

My sPath value coming is sPath = "/IssueDetailSet(Memberid='0000000001',Bookid='0000000001')"

saivellanki
Active Contributor
0 Kudos

KC,

Try using getProperty() method:


this.getView().byId("lineItemsList").getModel().getProperty("/IssueDetailSet");               // '/IssueDetailSet' will be your table items binding path

Regards,

Sai Vellanki.

Karan_Chopra_
Active Participant
0 Kudos

I have already referred the link JS Bin - Collaborative JavaScript Debugging but the problem there the table is created with JS but in my case with layout editor and because of that I am also not sure where to find ModelName as it is not defined anywhere while table creation.

I am getting data from oData services

saxos
Explorer
0 Kudos

Hello KC,

here's how i did it:

You have to give your table an ID. in my case "grTable".

The ColumnListItem in my Table:

<ColumnListItem press="onPositionsTableItemPress" type="Active"  >

And here's my onPositionsTableItemPress:

oSelectedModel is the Model in your JSON which was clicked on. In your case it would be smth like

.getModel().getData().splice(iSelectedItemIndex, 1):

Regards

Samuel

saivellanki
Active Contributor
0 Kudos

Hi K C,


Your model must be having a name, try passing the model name


var sPath = oItem.getBindingContext("yourModelName").getPath();

var oModel = oTable.getModel("yourModelName");

Regards,

Sai Vellanki.

saurabh_vakil
Active Contributor
0 Kudos

You can refer to the example here - JS Bin - Collaborative JavaScript Debugging