如何附加我的自定义运算符并保留其他运算符
我将MaterialUI的DataGrid用于React,并为其中一列创建了一个自定义筛选器运算符
我能够将它添加到文档中提到的列中,它运行良好,但是,这删除了其他默认运算符(contains、equal等(。
我就是这样做的:
columns: GridColDef[] = [
{
field: 'myFieldName',
headerName: 'Column name',
filterOperators: [MyCustomOperator],// this is the custom operator I have created
}
]
如何附加我的自定义运算符并保留其他运算符
我尝试了...getGridStringOperators()
,它在所有现有过滤器的末尾添加了新的过滤器。因此,对于您的情况,它将如下所示:
columns: GridColDef[] = [
...getGridStringOperators(),
{
field: 'myFieldName',
headerName: 'Column name',
filterOperators: [MyCustomOperator],// this is the custom operator I have created
}
]