Ag-Grid setRowData未在网格内部设置数据

时间:2019-10-29 19:46:10

标签: javascript angular ag-grid

我有一个运行良好的网格。我在下拉菜单中进行选择,以获取一组网格数据,效果很好。我正在使用一项服务来保留我所有选择和数据的值,因此,当用户导航回页面时,他们不必经历重新获取数据的整个过程。除网格数据外,所有值均保持不变。

我的onGridReady()函数如下:

  onGridReady(params) {
    this.gridApi = params.api;
    this.gridColumnApi = params.columnApi;

    if(this._forecastService.gridData.length > 0) {
      this.filterData();
      this.gridApi.redrawRows();
    } else {
      this.gridApi.showNoRowsOverlay();
    }
  }

filterData函数如下:

filterData() {
    let historyData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.history) {
        return row.Section === "History";
      }
    });

    let retailData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.retail) {
        return row.Section === "Retail";
      }
    });

    let volumeData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.volume) {
        return row.Section === "Volume";
      }
    });

    let nsiData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.nsi) {
        return row.Section === "NSI";
      }
    });

    let deadNetData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.deadNet) {
        return row.Section === "Dead NET";
      }
    });

    let executionData = this._forecastService.gridData.filter(row => { 
      if(this._forecastService.execution) {
        return row.Section === "Execution";
      }
    });

    this.filteredData = [...historyData, ...retailData, ...volumeData, ...nsiData, ...deadNetData, ...executionData];
    if(this.filteredData.length === 0 && this._forecastService.gridData.length > 0) {
      this.filteredData = [...this._forecastService.gridData];
    }

    this.gridApi.setRowData(this.filteredData);
  }

我已经设置了浏览器断点并逐步执行了代码。数据在那里,并且正如我期望的那样到达了setRowData(),除了网格中没有数据显示。

0 个答案:

没有答案