【发布时间】:2013-10-31 11:29:03
【问题描述】:
我有一个 ng-grid,我试图用一些搜索结果来填充它。 只要结果具有不同数量的行,查询就可以工作...... 如果查询与前一个查询具有相同数量的行......结果将不会显示。
// after a rest call
// we have the result
// #1 Clean gridData and local array
$scope.gridData.length = 0;
_labels.length = 0;
// #2 feed the grid
// these two functions add rows to the grid + data to the rows (and my local array)
addLabels(result.Labels);
addPhrases(result.Phrases);
// Second version attempting to call $scope.$apply
// does not work either
$scope.gridData.length = 0;
if (!$scope.$$phase) {
$scope.$apply();
}
_labels.length = 0;
addLabels(result.Labels);
addPhrases(result.Phrases);
if (!$scope.$$phase) {
$scope.$apply();
}
这是一个证明这一点的 plunker: http://plnkr.co/edit/gSFtuL?p=preview
请注意,如果您多推(或少推)一项,网格会刷新
【问题讨论】:
-
你定义了gripOptions吗?你能展示它和你的标记吗?