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.
Fired when the widget is bound to data from its data source. The event handler function context (available via the this keyword) will be set to the widget instance.
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
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With