cancel
Showing results for 
Search instead for 
Did you mean: 

Capture Row Data in sap.m.Table upon clicking button in the sap.m.ColumnListItem

Former Member
0 Kudos

Hello UI5 experts,

How can I capture the complete row data upon click of the Edit button in the last column. I have found similar issue in other threads and tried below, but not able to capture the row data.

var oItem = oEvent.getSource().getParent();
var iIndex = oEvent.getSource().getParent().getParent().indexOfItem(oItem);
	    
var sFirst = '/';
var sPath  = sFirst.concat( iIndex );	    
	    	    
var oTable = sap.ui.getCore().byId("idChangeTable1");
var model = oTable.getModel();
var obj = model.getObject(sPath); // This statement is not returning any values to me

capture.jpg

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor

HI

Here is an example.

http://jsbin.com/pulenom/edit?js,output

Please do not attempt the traversal the hierarchy to get the value.

Thanks

former_member224398
Participant

Rizwan,

https://sapui5.hana.ondemand.com is the only place where you can refer all the methods. Basically you need to refer the API for particular control. In that if you see that the parents controls methods also will be there.

Thanks,

Anurag

Former Member
0 Kudos

Hello Anurag,

In my case, when button in the table column is pressed, oEvent.getSource() will being me table object?

var oContext = oEvent.getSource().getBindingContext();
former_member224398
Participant

It will get the binding context of the particular row in the table. you can do console.log(oContext); to see the all the properties in the task in f12 window.

Former Member
0 Kudos

Thank you Anurag..

Answers (2)

Answers (2)

Former Member

Hi Mohammad,

Please try the below one:

var getTabledata = that.getModel("Items").getData().results;
var itemPosition = oEvent.getSource().getParent().getParent().indexOfItem(oEvent.getSource().getParent())
Once you get the item position, you can get the data of the complete row from below
var selctedRowdata = getTabledata[itemPostion]; // this has the complete row info

Regards

Madhu

Former Member
0 Kudos

Got errors regarding "that", can you explain its significance?

capture2.jpg

Former Member
0 Kudos

Thanks Dennis, your solution worked for me..

var oContext = oEvent.getSource().getBindingContext();
var oObject = oContext.getObject();

Thanks once again..