Pramod Karandikar
Pramod Karandikar

Reputation: 5329

Angular ag-grid: Load column data lazily

I have a peculiar problem to address. I am using ag-grid enterprise version and the data is loaded in the grid using Angular/NgRx with SpringBoot in the backend. There are 10 columns in the grid and 9 of them are pretty easy to load from the database. The remaining column is a bit complex to process on backend and it hampers the overall grid load time.

Here's what I am looking for:

Upvotes: 0

Views: 1734

Answers (1)

Josef Bláha
Josef Bláha

Reputation: 1113

Split your query in two:

  • The first will load the data with 9 columns and fill the grid. The 10th column will have some placeholder value.
  • The second query will load values of the remaining column and once completed, you can update grid data like this:
const withCol10 = [
{
    id: 1,
    col10: 42
}
// ...
];
this.gridApi.forEachNode(rowNode => {
  const original = rowNode.data;
  const updated = withCol10.find(i => i.id === original.id);
  if (!updated) {
    rowNode.setData({
      ...original,
      ...updated
    });
  }
});

See docs for more details.

Upvotes: 1

Related Questions