ngtreegrid icon indicating copy to clipboard operation
ngtreegrid copied to clipboard

Add data at run time.

Open coolvijaymca opened this issue 3 years ago • 2 comments

Trying to configure data at run time but data is not displaying. at starting data is blank.

`hoursData: any[] = []; configs: any = {
'group_by': 'type', 'group_by_header': 'Product Type', 'group_by_width': '100px', 'columns': [{ 'header': 'Product Name', 'name': 'name', 'sortable': false }, { 'header': 'Price', 'name': 'price', 'width': '200px', 'group_aggregator': (array) => { const prices = array.map((item) => item.price); return '$' + prices.reduce((acc, item) => acc + item); } }] };

    var i = 1;
    for (const value of iPlanned) {
      let restallx = { type: 'Planned', name: value.Month, price: value.Hours };
      i++;
      this.hoursData.push(restallx);
    }
    i = 1;
    for (const value of iEstimated) {
      let restallx = { type: 'Estimated', name: value.Month, price: value.Hours };
      i++;
      this.hoursData.push(restallx);
    }
    i = 1;
    for (const value of iActual) {
      let restallx = { type: 'Actual', name: value.Month, price: value.Hours };
      i++;
      this.hoursData.push(restallx);
    }
    this.angularGrid.store.setRawData(this.hoursData);
    this.angularGrid.store.processData(null, null, null, null);
    this.angularGrid.store.refreshDisplayData();
    this.angularGrid.expandAll();`

Data is available in array however not displayed. Console displayed 'ngtreegrid.js:327 Data should not be empty!'

Can you tell us how to refresh data.

coolvijaymca avatar Oct 08 '20 20:10 coolvijaymca

Have you tried this.hoursData = updatedData?

debabratapatra avatar Oct 09 '20 14:10 debabratapatra

I did, I even tried this.angularGrid.data = updatedData; but no result. This should replace previous data with new data but not did the work

coolvijaymca avatar Oct 12 '20 17:10 coolvijaymca