Method injected inside header of data grid is being called for each data cell rendering and also being called when we do horizontal or vertical scroll . For reproducing this issue i have attached plnkr link here . http://plnkr.co/edit/ZW43LsiLY7GdnX6XEOgG?p=preview , http://plnkr.co/edit/3E8HTz4Z2daGqRh1WHtx?p=preview (<div class="ui-grid-top-panel" style="text-align: center">{{grid.appScope.letter()}}</div>
, try sorting , horizontal or vertical scroll ).
在数据网格的头内注入的方法被称为每个数据单元呈现,当我们做水平或垂直滚动时也被调用。为了复制这个问题,我在这里附加了plnkr链接。http://plnkr.co/edit/ZW43LsiLY7GdnX6XEOgG?p =预览,http://plnkr.co/edit/3E8HTz4Z2daGqRh1WHtx?p=preview (
For instance : Below is header cell view template, we have injected {{ grid.appScope.getHeaderLetter( col.name, $parent.$index )}}
and when we do horizontal or vertical scroll or at the time of initial cell rendering getHeaderLetter method is being called for each data cell. In another words if we have 100000 cells then method is being called 100000 times. I think I am missing some important fact in terms of use cases . I would highly appreciate your comment on this.
例如:下面是头单元格视图模板,我们已经注入了{{grid.appScope}。getHeaderLetter(col.name美元的父母。$index)}当我们进行水平或垂直滚动时,或者在初始单元格呈现时,将为每个数据单元格调用getHeaderLetter方法。换句话说,如果我们有100000个细胞那么方法就被称为100000次。我认为我在用例方面漏掉了一些重要的事实。我将非常感谢你对此的评论。
----Header Definition----
- - - - - - - - - -头定义
<div class="ui-grid-top-panel ui-grid-top-panel-single" id="{{'ui-grid-index-' + col.name }}" style="text-align: center">
<div class="ui-grid-alphbet ui-grid-alphbet-first">{{ grid.appScope.getHeaderLetter( col.name, $parent.$index ) }}
</div>
.
.
.
more code
I have asked the same question here ... https://github.com/angular-ui/ui-grid/issues/4250, but didn't got any reply.
我也问过同样的问题……https://github.com/angular-ui/ui-grid/issues/4250,但是没有得到任何回复。
1 个解决方案
#1
2
this is the way angular dirty-checking works. not much you can do about it. just try not to put long-running operations in such functions.
这就是角测定仪的工作方式。你对此无能为力。不要把长时间运行的操作放在这些函数中。
how about this:
这个怎么样:
$scope.letterFn = function () {
console.log("CHANGE LETTER")
return i;
}
$scope.letter = $scope.letterFn();
http://plnkr.co/edit/yF1sSG2QXeO9cFNAeDYm?p=preview
http://plnkr.co/edit/yF1sSG2QXeO9cFNAeDYm?p=preview
#1
2
this is the way angular dirty-checking works. not much you can do about it. just try not to put long-running operations in such functions.
这就是角测定仪的工作方式。你对此无能为力。不要把长时间运行的操作放在这些函数中。
how about this:
这个怎么样:
$scope.letterFn = function () {
console.log("CHANGE LETTER")
return i;
}
$scope.letter = $scope.letterFn();
http://plnkr.co/edit/yF1sSG2QXeO9cFNAeDYm?p=preview
http://plnkr.co/edit/yF1sSG2QXeO9cFNAeDYm?p=preview