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

AngularJS $scope.grid is undefined

4 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antje
Top achievements
Rank 1
Antje asked on 29 Jul 2014, 02:00 PM
Hey there,

I read a blog article from Burke Holland (http://blogs.telerik.com/kendoui/posts/14-02-26/a-few-angular-kendo-ui-best-practices) and in the chapter "Leverage Widget References" he says, that the widget reference to the grid is provided inside the scope.

But when I use this html snippet:

<div kendo-grid="grid" k-options="mainGridOptions"></div>

and try to use $scope.grid in my controller, it is undefined.


Would you please provide an example how to get the widget reference?

Thanks a lot!

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 31 Jul 2014, 11:04 AM
Hello Antje,

Here is an example that you can see the Grid is within a variable inside the controller context:

http://dojo.telerik.com/@pesho/aGaB

I hope this is what you are searching for.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mike
Top achievements
Rank 1
answered on 22 Oct 2015, 07:17 PM
I'm having the same issue. Can you post the details (or different ways) on getting reference to the grid? The example is not helping me.
0
Mike
Top achievements
Rank 1
answered on 22 Oct 2015, 07:42 PM

OK I solved this by listening to the global 'kendoRendered' event:

 

$scope.$on('kendoRendered', function() {

console.log($scope.myGrid);

});

0
Kiril Nikolov
Telerik team
answered on 26 Oct 2015, 09:58 AM

Hello Mike,

 

You need the event, in order to make sure that the instance is available, when you try to access it. So the recommended event is either kendoRendered or kendoWidgetCreated.

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Antje
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Mike
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or