定制AG-网格滤波器使用下拉用于使用过滤特定列反应-终极版

问题描述 投票:1回答:2

我的工作需要AG-网过滤器外与下拉菜单,将筛选出的一列结果的项目。

我曾尝试使用这种反应,终极版的形式来做。

<select id="ddl" className="custom-select" onChange={this.jsFunction(this)}>
    <option >Search category name</option>
    <option value="1">1</option>
    <option value="2">2</option>
</select>

的下拉的变化值应使用反应和Ag-网格被滤除。

reactjs redux react-redux ag-grid ag-grid-react
2个回答
0
投票

您可以使用AG-电网的能力做横跨所有列过滤quick filter,你可以自定义要应用于特定的列


0
投票

你应该能够做到这一点使用AG-网格External Filters

快速过滤器是首选,如果你想要做一个过滤器对整个电网和你比较功能最终会被复杂的,如果你想从刚一列进行过滤。

在你的HTML,你可以做onChange={this.jsFunction($event.target.value)}

jsFunction(filterVal) {
    this.filterVal= filterVal;
    gridOptions.api.onFilterChanged(); //this invokes your custom logic by forcing grid filtering
}

function doesExternalFilterPass(node) {
    if (this.filterVal) {
        return node.data.yourColumnValue === this.filterVal;
     }
    return true; //default case return all rows
   }

最后,更新您的网格配置

isExternalFilterPresent: true,
doesExternalFilterPass: doesExternalFilterPass

你可以找到官方的例子here

© www.soinside.com 2019 - 2024. All rights reserved.