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
0
Hi,
You need to get the grid instance from the element in order to bind events to it. Here is how:
Regards,
Atanas Korchev
Telerik
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
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
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!