A while ago, I developed a grid component to use in an Angular application. Each Grid
has a number of rows, each of them being a Row
component, and each Row
has cells, that are also components, named Cell
. Each cell can have a number of "objects" that basically are div
tags with some styling and event listeners attached. Visually:
The reason of this design was the different functionalities that the components should provide to the user. For example, the grid component is responsible of getting the bulk data from the API, parsing it and build as many rows as needed. The row components can be disabled, tagged, moved above/below, create a new row, etc and they receive the data from the parent grid via @Input
properties and build the cell components, also using @Input
to pass their content. These cell components have any number of objects (these are not components) that can be dragged and dropped, deleted, cloned, etc.
This approach has been working fine until we had to manage big grids. In this case, the application becomes quite sluggish and it's almost unusable. I know that the reason is the enormous number of components being created, with their corresponding event listeners and all the stuff. To avoid this problem, it's mandatory to implement some sort of virtual scrolling, but I can't find how to do it, as the rows can have very different heights. So my question is, is there any mechanism that allows me to "sleep" the created componentes while they're not being displayed on screen? The Grid
, Row
and Cell
components all use the OnPush
change detection strategy, but it's being triggered constantly, when the user hovers a cell, an object, etc.
I'm implementing a pagination system, but there are cases when we'd need to display the sequence of all the rows and I don't know if it'll be possible with the current approach.
Any suggestion? Thanks in advance!