cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sap.m.table and sap.ui.commons syntax difference

Former Member
0 Likes
2,429

Hi All,

Sometime back, I was working on Tables and I used sap.ui.commons library. In the table, I have created a toolbar. When a row is selected and "display button" from the toolbar is clicked, a dialog box opens up , and details of that item are shown in that dialog box.

Screenshot of the code -

Now I am using SAP.M. library. But I am facing an issue while getting the "rowcontext". I tried various options, but I am not able to get the rowContext. Can anyone please help me with the syntax.

In debug mode, I can see that my oContext is undefined.

I want to access the values that are marked in RED in the screenshot -

example - AProject, ATitle, AUnid....... Please help me in this

Regards

Meenakshi

Accepted Solutions (1)

Accepted Solutions (1)

former_member340030
Contributor
0 Likes

Hi Meenakshi ,

If you want to get the attached data to the selected item than you can just simply get the bindingContext of the selected Item..

var sItem = oTable.getSelectedItem();

var sData = sItem.getBindingContext("this is your model name attach to the table").getProperty();

sData will have the data attach to the row you have selected

thanks

Viplove

Former Member
0 Likes

HI Viplove,

Thanks for your reply. I am getting an error - Uncaught TypeError: Cannot read property 'getProperty' of undefined

former_member340030
Contributor
0 Likes

Hi Meenakshi

Did you provide your model name in the binding context if you have mentioned while binding data to the table if not than leave it blank ..

Thanks

Viplove

Former Member
0 Likes

what should be passed in the model name ?

Former Member
0 Likes

I want to access the values that are marked in RED in the screenshot -

example - AProject, ATitle, AUnid....... Please help me in this

former_member340030
Contributor
0 Likes

Hi ,

As you have assigned the model to the core and without any model name , so you can access bindingContext without model name. So just try the below code. Below code give you just the one selected row data not the whole table data

var sItem = oTable.getSelectedItem();

var sData = sItem.getBindingContext().getProperty();

Thanks

Viplove

Former Member

Thanks Viplove, It worked 🙂

Thank you so much 🙂

Answers (1)

Answers (1)

rohit_darwade
Explorer
0 Likes

Hi,

You can get the binding context on click on table line Items:

var object=oEvent.getSource().getParent().getModel().getProperty(oEvent.getSource().getBindingContext().sPath);

Thanks,

Rohit.

Former Member
0 Likes

Hi Rohit,

Thanks for your reply. What should be passed in spath ? I am getting an error - Cannot read property 'sPath' of undefined

Thanks and Regards

Meenakshi

Former Member
0 Likes

I want to access the values that are marked in RED in the screenshot -

example - AProject, ATitle, AUnid....... Please help me in this

Ask a Question