Skip to Content
0

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

May 28, 2017 at 12:49 PM

151

avatar image

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

capture.png (23.6 kB)
capture1.png (25.9 kB)
code.png (73.9 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
VIPLOVE KHUSHALANI May 29, 2017 at 07:14 AM
0

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

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

HI Viplove,

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

0

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

0

what should be passed in the model name ?

model-name.png (8.3 kB)
0

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

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

code.png (73.9 kB)
0

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

0

Thanks Viplove, It worked :)

Thank you so much :)

1
Rohit Darwade May 29, 2017 at 04:55 AM
0

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.

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

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

0

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

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

code.png (73.9 kB)
0