Skip to Content
0

Unable to pass values from my table row to dialog box sap ui5

Apr 30, 2017 at 09:46 AM

166

avatar image

Hi All,

In my table, I have created a toolbar which has a display button. When the display button is clicked, a dialog box opens and the data of the selected row is passed to it. But while doing so, I am getting an error - "Uncaught TypeError: oTable.attachRowSelect is not a function".

1. My table -

2. Dialog box -

3. Code -

Please let me know what I am doing wrong?

Regards

Meenakshi

dialog-values.png (30.2 kB)
table.png (36.2 kB)
dialog-box.png (50.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Akhilesh Upadhyay May 01, 2017 at 09:06 AM
0

to get the context no need to attach row selected event, even you can get that using row index, check below code may help you

var ind = oTable.getSelectedIndex();

var selectedRow = this.oTable.getAggregation("rows")[ind]

var oContext = selectedRow.oBindingContexts;

//now you can get path from oContext and get property value from model i.e. oModel.getProperty(path + "/AProject");

// or you can get direct values from cells from selectedRow

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

Hi Akhilesh,

Thanks for your reply. Sorry to ask this. But what should be passed in "rows" ? (var selectedRow = this.oTable.getAggregation("rows")[ind] )..

I am getting an error - Uncaught TypeError: Cannot read property 'getAggregation' of undefined

0
Former Member
Meenakshi Raina

you're passing the reference of the table as this.oTable.getAggregation("rows") whereas it has to be oTable.getAggregation("rows")

0

no need to pass anything, thats aggregation of the table, and yes i think small typo i did, remove this keyword, you got error due to table was not found in that particular line of code

oTable.getAggregation("rows")[ind];

0

I tried to use this. But in debugging , the object remains undefined -

debug.png (33.0 kB)
0

all well, till now your code is correct. you are getting an object in oContext along with one property i.e. undefined

that undefined is nothing but model name, if you have named model then it should be displayed here instead of undefined.

you can get path as : selectedRow.oBindingContexts.undefined.sPath

0
Sharath M G Apr 30, 2017 at 10:29 PM
0

why are you attaching the function of the table inside the toolbar? It should be outside toolbar .

Check it .

Regards,

Sharath

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

Hi Sharath,

Thanks for your reply. This is because I wanted to select the data of the particular row of the table. and then pass it to the dialog box. So I am using attachrowSelect event for that.

Please guide me if I am doing wrong.

Regards

Meenakshi

0

The event is when user selects the row of the table. You could check to attach it to table. In the toolbar you can always get the selected rows

0
Meenakshi Raina May 28, 2017 at 12:27 PM
0

Hi, just wanted to add the code that worked for me -


capture.png (23.6 kB)
Share
10 |10000 characters needed characters left characters exceeded