我怎样才能刷新网格数据源采用了棱角分明的剑道UI [英] How can I refresh a grid data source using angular Kendo UI
问题描述
我与角度使用角度剑道UI项目结合Telerik的剑道网格。
I am combining Telerik Kendo grid with Angular using the Angular Kendo UI project.
我有以下标记:
<div kendo-grid="" k-options="thingsOptions" style="height: 600px;" />
和以下code在我的控制器:
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();
在我的控制器。但似乎有点不对劲不得不选择从我的控制器中的HTML元素。
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>
参考:<一href=\"http://blogs.telerik.com/kendoui/posts/14-02-26/a-few-angular-kendo-ui-best-practices\">http://blogs.telerik.com/kendoui/posts/14-02-26/a-few-angular-kendo-ui-best-practices
这篇关于我怎样才能刷新网格数据源采用了棱角分明的剑道UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!