This is a migrated thread and some comments may be shown as answers.

Retrieving dataSource object from custom popup tempate after button clicked in popup

4 Answers 261 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 23 Feb 2017, 04:14 PM

I'm trying to get the dataSource dataItem for a grid value after I have brought up a custom popup screen.  I've created a button on the custom popup, and I'm passing the UID to the click event and I can get the row of the grid, however I'm trying to get the datasource dataItem and have had no luck.  I've create the following dojo:   http://dojo.telerik.com/@pnd@qad.com/oYIXU/2

I've also attached a screenshot of the developer tools which shows my dataItem is undefined, what I need is the dataItem so that I can pass that on to another call.  Any help is greatly appreciated.

4 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 24 Feb 2017, 12:48 PM
Hello Paul,

Thank you for the provided runnable example.

The reason the data item was not retrieved properly was the UID was passed as a string with spaces before and after the actual UID. I have modified the dojo accordingly, and also included another approach of retrieving the data item - via the Grid dataItem() method. Both dataSource.getByUid() and dataItem() return the same item, and you can choose one in accordance with your preference:

http://dojo.telerik.com/ivIREM

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paul
Top achievements
Rank 1
answered on 24 Feb 2017, 12:56 PM

Works great!  I love the forums.....

 

Quick question - how could I pass the data not as a string?  Is it possible to pass the entire data object from the template button click?  I could not figure out how to do it without it blowing up, that's why I did the stringing of the value and passed that to get it in the next function.

0
Dimiter Topalov
Telerik team
answered on 24 Feb 2017, 02:40 PM
Hi Paul,

The most straightforward approach would be to store the respective data item in a variable, accessible in the template, and use it as a parameter to the button click handler:

http://dojo.telerik.com/ivIREM/2

There is no trivial way to pass the whole data item in the template, using the current approach.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paul
Top achievements
Rank 1
answered on 24 Feb 2017, 03:04 PM
Thanks again. Can not tell you how much I've learned from the forums.  You are doing a great job at helping.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or