Gratz44
Gratz44

Reputation: 45

Why is my angular grid so slow?

So, I have made some custom directive which draws kind of a data-grid, based on floated divs (because nested flex implementation in FF sucks - but it's not the point).

How it works :

The problem is that every time I'm hitting some "up" or "down" key on my keyboard, Angular is "redrawing" EVERY cells of the list.

So, let's suppose I've 200 rows in my data list, and 7 columns for each rows. First load of the page, it passes ~3000 times in the renderCell() function. Ok , let's accept that (don't really understand why, but ok).

I hit the down key in order to go to the second line of my list. It passes ~1100 times in the renderCell() function.

So yes, the result is very slow (imagine if I let the down arrow key pressed in order to quick navigate within my rows)... I can't accept that. If someone could explain that to me... Any help would be greatly accepted :)

If I make the same thing without a directive (direct DOM manipulation, with columns made by hand and not in a ng-repeat within a ng-repeat), every thing is smooth and clean.

Yes, I've look into every angular grid on the market. No one is satisfying me for my purpose, that's why I've decided to create my own one.

And no, I really can't give you some JSFiddle or anything for the moment. The whole app is really tentacular, isolating this is some kind of complicated).

Upvotes: 0

Views: 1622

Answers (1)

YD1m
YD1m

Reputation: 5895

Try to use bind once (angular 1.3+)

<div data-ng-repeat="row in ::list">
    <div data-ng-repeat="cell in ::theGridColumns"
         data-ng-bind-html="::(renderCell(row, cell))">
    </div>
</div>

Upvotes: 2

Related Questions