【问题标题】:ag-grid: Disable sorting and filtering in the RowModel, but not the UIag-grid:禁用 RowModel 中的排序和过滤,但不是 UI
【发布时间】:2019-07-22 16:45:26
【问题描述】:

我使用的 ag-grid 从外部数据源对象获取数据。该对象处理行的排序和过滤,并在完成后为 ag-grid 提供新的rowData

但我仍然希望能够使用 ag-grid 中的过滤器字段并单击标题以更改排序。只是它不应该自己进行排序和过滤,而是通知外部对象。

有没有办法做到这一点?

我试图用假人覆盖模型的doSortdoFilter,但这完全破坏了网格。由于他们没有返回值,我希望他们只是修改他们作为参数获得的对象,并且可以像这样跳过。

this.gridApi.getModel().doFilter = () => {};
this.gridApi.getModel().doSort = () => {};

【问题讨论】:

    标签: ag-grid


    【解决方案1】:

    好的,再看一下 ag-grid 代码,我想我找到了一个解决方案,它使用了我原来的覆盖私有方法的 hacky 方法。 :/

    this.gridApi.getModel().doFilter = function (changedPath) {
      changedPath.forEachChangedNodeDepthFirst((rowNode) => {
        rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
        rowNode.setAllChildrenCount(null);
      }, true);
    };
    this.gridApi.getModel().doSort = function () {
      this.rootNode.childrenAfterSort = this.rootNode.childrenAfterFilter.slice(0);
    };
    

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 2019-12-29
      • 2021-09-11
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 2017-10-25
      • 2020-07-18
      • 2021-08-06
      相关资源
      最近更新 更多