如果开始单元格编辑,如何禁用Ag网格中的所有过滤器

时间:2020-07-22 02:46:03

标签: angular typescript ag-grid ag-grid-angular

我在项目中使用Ag网格。我想关闭过滤,禁用Grid中所有可用的过滤器。 我的网格在单元格值更改时发出事件,因此我可以在那里听和做逻辑。

<div class="grid-container">
  <ag-grid-angular
    class="ag-theme-bootstrap"
    [columnDefs]="columnDefs"
    [modules]="modules"
    [frameworkComponents]="frameworkComponents"
    [gridOptions]="gridOptions"
    [headerHeight]="null"
    (cellValueChanged)="updateCellData($event)"
    (cellDoubleClicked)="setColumnWidth($event)"
    (filterChanged)="filterMod($event)"
    (sortChanged)="filterMod($event)"
  >
  </ag-grid-angular>
</div>

所以(cellValueChanged) = updateCellData($event)在此更新单元格数据中试图关闭过滤功能,但没有用。

/**
 * An event triggered when user will finish editing cell
 * and move to another cell
 * @pram param is passing the new value of cell
 */
public updateCellData(dataObj) {
  this.gridOptions.api.floatingFilter = false; //-----------> Here i tried to disable this
  // this.cellDataChange.emit(param);
  let data = dataObj.data;
  let existingIds = this._gridDataArr.map((obj) => obj.id);
  if (!existingIds.includes(data.id)) {
    this._gridDataArr.push(data);
    // this._summaryDataArr.push(this.createSummary(dataObj));
  } else {
    this._gridDataArr.forEach((element, index) => {
      if (element.id === data.id) {
        this._gridDataArr[index] = data;
        // this._summaryDataArr[index].summary.push(this.createSummary(dataObj).summary[0]);
      }
    });
  }
}

我也尝试过this.gridOptions.floatingFilter = false;//,但是失败了

0 个答案:

没有答案