我在网格数据的Angular ng-Repeat和serach选项中有kendo-grid。 我想在搜索时刷新网格。
这是我的代码并且它不刷新网格($("#kendoGrid1").data("kendoGrid")
未定义),对此有什么解决方法?
HTML
<article ng-repeat="(key,val) in gridsResult" >
<h2 class="tableTitle">{{key}}</h2>
<div kendo-grid="kendoGrid{{$index}}" k-options="getGridSlice('{{key}}')"></div>
</article>
JS
$scope.getGridSlice = function (index) {
var data = $scope.gridsResult[index];
return {
dataSource: {
data: data
}
},
columns: [
{ field: "aa", title: " ", attributes: { "class": "k-header",style:"text-align:center;" }, width:"33px" },
{ field: "bb", title: "IF", template: rowTemplate.replace(/XX/g, 'IF')}
],
scrollable: false,
noRecords: true,
}};
scope.onSearch函数 -
$("#kendoGrid1").data("kendoGrid").datasource.read();
答案 0 :(得分:1)
我找到了答案!
$ digest不能用于函数,所以我添加了基于范围参数而非范围函数的k-data-source。 (您需要从按网格类别分组的数据库中提取数据)
<article class="tradescreenTable" ng-repeat="(key,val) in gridsResult" ng-class="{'bestAverage': bestAverageSelected}">
<h2 class="tableTitle">{{key}}</h2>
<div kendo-grid k-data-source="{{val}}" k-options="gridOptions"></div>
</article>
和k-options
$scope.gridOptions = {
columns: [
{ field: "aa", title: " ", attributes: { "class": "k-header",style:"text-align:center;" }, width:"33px" },
{ field: "bb", title: "IF", template: rowTemplate.replace(/XX/g, 'IF')}
],
scrollable: false,
noRecords: true,
};
答案 1 :(得分:0)
您还需要刷新网格:
$("#kendoGrid1").data("kendoGrid").datasource.read();
$("#kendoGrid1").data("kendoGrid").refresh();
答案 2 :(得分:0)
kendo-grid="kendoGrid{{$index}}"
将网格绑定到$scope
- 您不需要为此使用jQuery(此外,您还没有在id
上设置$("#kendoGrid1")
DOM元素,因此$scope.kendoGrid1.datasource.read();
永远不会像现在一样使用您的代码。
{{1}}
有一点需要注意的是,我还没有尝试动态设置剑道网格的名称,所以我不是100%它的工作原理。