I am combining Telerik Kendo grid with Angular using the Angular Kendo UI project.
I have the following markup:
<div kendo-grid="" k-options="thingsOptions" style="height: 600px;" />
and the following code in my controller:
$scope.thingsOptions = {
dataSource: {
type: "json",
transport: {
read: "/OM/om/getAssets",
dataType: "json"
},
schema: {
model: {
id: "ProductID",
...
This all works fine however I would like to force a data source refresh of my grid from my controller. something like
$scope.getTasks = function() {
$scope.thingsOptions.dataSource.read();
};
Is this possible to do from the controller? I could always do something like
$("#taskGrid").data("kendoGrid").dataSource.read();
In my controller. But it seems a bit wrong to have to select a HTML element from my controller.
Just pass in a scope variable to the directive, then inside of your controller you can use the variable to call whatever widget methods you need.
<div kendo-grid="grid" ...></div>
<script>
...
$scope.getTasks = function() {
// scope.grid is the widget reference
$scope.grid.refresh();
}
...
</script>
Ref: http://blogs.telerik.com/kendoui/posts/14-02-26/a-few-angular-kendo-ui-best-practices