How can I refresh a grid data source using angular Kendo UI
42,780
Solution 1
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
Solution 2
Your datasource must be a kendo object
$scope.thingsOptions = {
dataSource: new kendo.data.DataSource({
type: "json",
transport: {
read: "/OM/om/getAssets",
dataType: "json"
},
schema: {
model: {
id: "ProductID",
then it is possible to call
$scope.thingsOptions.dataSource.read();
Related videos on Youtube
Author by
David Kethel
Updated on July 05, 2022Comments
-
David Kethel almost 2 years
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.
-
Agent_K about 9 yearsGreat answer, but unfortunately this doesn't work if you change dataSource and columns. The KendoUi-Grid doesn't support defining columns after the widget is created - as is stated here: kendo-labs.github.io/angular-kendo/#/grid-widget. Any idea how to achieve that? Probably you have to go to another route and thus reload the child template ...
-
Halcyon over 8 yearsI can confirm this as well. I had to use $scope.grid.dataSource.read(). I'm using the 2015.3.930 library.
-
micjamking about 8 yearsYou have to pass in $scope to use those methods.
-
Pankaj Parkar about 8 years@micjamking somehow this doesn't work, I solved my problem with by this answer
-
Immortal over 7 yearsthis is a better answer compared to the accepted one, gives more control of what to do.