ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Method injected inside header of data grid is being called for each data cell rendering.

Open suryasingh opened this issue 11 years ago • 5 comments

hello , I have found that , 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/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.

----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 
``` javascript
----------------------------------

suryasingh avatar Aug 24 '15 10:08 suryasingh

Are you sure it's being called for each data cell. Logically it'd be called for each column if you put it in the header. If you've put something in the cellTemplate, then it'd be called for each rendered cell (because of virtualisation this isn't every cell in the data).

PaulL1 avatar Aug 24 '15 18:08 PaulL1

yeah , it's being called for each data cell.

suryasingh avatar Aug 25 '15 10:08 suryasingh

hi @PaulL1 i have put the function in header n it's being called for each data cell. I have created a plnkr for the same http://plnkr.co/edit/iRvZol4iL3zOsZBXOpIh?p=preview

<div class="ui-grid-top-panel" ng-init="i=0" style="text-align: center">{{i=i+1}}</div>

try sorting n horizontal scroll in the above plnkr , u'l notice a sudden change in the value of ' i ' .

suryasingh avatar Aug 26 '15 11:08 suryasingh

@PaulL1 i have updated the plnkr. http://plnkr.co/edit/ZW43LsiLY7GdnX6XEOgG?p=preview

suryasingh avatar Sep 02 '15 16:09 suryasingh

Hey folks, I'm experiencing the same issue here. Any word on this? Seems to me that any methods in the header template get fired off excessively when any ui operation is performed (most noticeable is in scrolling where the method is often called over 100 times), resulting in pretty dramatic performance issues. In my case , the value in the header itself has not been modified so it shouldn't require rerendering. Perhaps we could use a tracking expression to exclude it from the digest loop? Have you seen any solutions to this issue? Thanks so much for all of your work on this library!

spencerhandley avatar Sep 09 '15 15:09 spencerhandley