cancel
Showing results for 
Search instead for 
Did you mean: 

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

meenakshi_raina
Advisor
Advisor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member227918
Active Contributor
0 Kudos

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

meenakshi_raina
Advisor
Advisor
0 Kudos

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

former_member183518
Active Participant
0 Kudos

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

former_member227918
Active Contributor
0 Kudos

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];

meenakshi_raina
Advisor
Advisor
0 Kudos

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

former_member227918
Active Contributor
0 Kudos

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

Answers (2)

Answers (2)

meenakshi_raina
Advisor
Advisor
0 Kudos

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

Sharathmg
Active Contributor
0 Kudos

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

Check it .

Regards,

Sharath

meenakshi_raina
Advisor
Advisor
0 Kudos

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

Sharathmg
Active Contributor
0 Kudos

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