Skip to Content
0

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

Jul 06, 2017 at 07:38 PM

108

avatar image

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

capture.jpg (38.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Dennis Seah
Jul 07, 2017 at 07:36 AM
1

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

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

1

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();
0

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.

1

Thank you Anurag..

0
Madhusudhan S Jul 06, 2017 at 08:01 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

capture2.jpg

capture2.jpg (33.7 kB)
0
Mohammad Rizwan Jul 07, 2017 at 07:56 AM
0

Thanks Dennis, your solution worked for me..

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

Thanks once again..

Share
10 |10000 characters needed characters left characters exceeded