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

[Solved] how to attach angularjs directive to kendo gird events

7 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wit
Top achievements
Rank 1
Wit asked on 19 Jan 2015, 11:49 AM

How could I attach angularjs directive to kendo ui gird databound event?
Should I take any additional steps when grid is destroyed? 

<
div id="kgrid" kendo-grid="kgrid" options="opGrid" my-grid-auto-size></div>

.directive(
'myGridAutoSize', function (UIService) {
               return {
                restrict: 'A',
                link: function (scope, element, attrs, location) {
                    element.bind('dataBound', function () {
                        UIService.ResizeGrid();
                    });                  
                }
            }
});

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 21 Jan 2015, 08:24 AM
Hi,

You need to get the grid instance from the element in order to bind events to it. Here is how:

link: function (scope, element, attrs, location) {
     var grid = element.data("kendoGrid");
     grid.bind('dataBound', function () {
         UIService.ResizeGrid();
     });                 
 }



Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wit
Top achievements
Rank 1
answered on 21 Jan 2015, 09:30 AM
Should I unbind my event when I move to another screen ? Or will it happen anyway? 
0
Wit
Top achievements
Rank 1
answered on 21 Jan 2015, 09:31 AM
Should I unbind my event when I move to another screen ? Or would that happen automatically? 
0
Wit
Top achievements
Rank 1
answered on 21 Jan 2015, 09:52 AM
I am getting undefined for grid :  var grid = element.data("kendoGrid");. Would you have any suggestions?
0
Accepted
Kiril Nikolov
Telerik team
answered on 23 Jan 2015, 08:26 AM

Hello Witek,

The problem is caused by Kendo UI Grid not being initialized when the directive is executed. This is why you can wrap the bind statement into a $timeout, so it is executed after the Grid has been initialized:

http://dojo.telerik.com/@Kiril/apuBA

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wit
Top achievements
Rank 1
answered on 23 Jan 2015, 11:46 AM
Thank you
0
Kiril Nikolov
Telerik team
answered on 23 Jan 2015, 01:19 PM

Hello Witek,

Glad I helped.

In case you have any further questions, please do not hesitate to contact us.

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
Wit
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Wit
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or