具有服务器端行模型的外部过滤网格

时间:2020-02-28 23:02:06

标签: reactjs ag-grid

ag-grid的反应/节点应用服务器端数据 OnFilterChanged和IsExternalFilterPresent都被触发,但是didExternalFilterPass不会被触发。我试着绑定功能,甚至强制触发。还尝试使IsExternalFilterPresent始终返回true,但仍然无法正常工作。与文档示例和我的项目的主要区别在于,我正在使用服务器端数据。如果它不起作用,则在文档中没有任何地方指出它只是客户端(不同于明确指定的快速过滤器)。

编辑:我的代码上的生命周期逻辑。我不知道添加从服务器端获取数据的方式是否相关。但是,这是我为外部滤波器添加的主要逻辑。这是在呈现agGrid的类组件内部。

// On state change trigger filter change
componentDidUpdate (prevProps, prevState) = {

        const filterChange = (prevState.filterDashboard !== this.state.filterDashboard);

        if(filterChange){
            console.log('filter triggered')
            this.state.gridAPI.onFilterChanged()
        }
}


// functions passed to my agGrid component
isExternalFilterPresent = () => {
    console.log('filter present', this.state.filterDashboard);
    // only trigger does filter pass if the filter is true
    return this.state.filterDashboard
}

doesExternalFilterPass = (node) => {
     console.log('filter pass', node)
     if(this.state.filterDashboard){
        for(let key in node.data){
           if(node.data[key].toString().includes(this.state.filterString)) return true
          }
        } else return true
}

0 个答案:

没有答案
相关问题