Alan2
Alan2

Reputation: 24572

If I use ng-show to hide columns in a large grid will that improve performance?

I have a large data grid with 20 columns and about 1,000 rows. The grid displays slowly and seems jerky to move with the scrollbar.

There are 5-6 columns that most of the time I don't need to see. If I used ng-show to hide those columns from view would that be likely to improve performance. Alternatively are there any other suggestions that might help me with this problem? I'm using v1.5.0 and the very latest browsers. Would upgrading to a more recent version help?

Upvotes: 0

Views: 49

Answers (2)

Developer
Developer

Reputation: 6440

  • ng-show renders the html, just that it hides that; so not gonna improve any performance. ng-if will not render the html; so use ng-if instead.

  • I would suggest server side pagination/lazy loading/infinite scroll as 1000 rows will not be readable.

  • While rendering if you dont need two way binding use one-time binding {{::}} syntax

Upvotes: 3

dimson d
dimson d

Reputation: 1660

replacing ng-show by ng-if will make huge improvement for performance. then using one time binding. also try to not use function in huge ng-repeat data. for example ng-class="user.getClass(item)". and less filters. plus infinite load help you or even better using paginator. plus turning off debugInfo

app.config(['$compileProvider', function ($compileProvider) {
    $compileProvider.debugInfoEnabled(false);
}]);

Upvotes: 0

Related Questions