【发布时间】:2020-09-30 02:33:44
【问题描述】:
我有 agGrid,其中包含使用 refData 属性的列。它显示为“是”或“否”,但基础值为“1”或“0”。我想按数据过滤列,但按“是”或“否”过滤时没有给出任何结果。但是,当我放置基础数据(即 1 或 0)时,过滤器开始工作。
HTML 文件
<ag-grid-angular class="ag-theme-balham"
[rowData]="categoryRowData" [columnDefs]="categoryColDef" [domLayout]="domLayout"
(gridReady)="onGridReady($event)">
</ag-grid-angular>
TS 文件
export class CategoryComponent implements OnInit{
private domLayout;
private objCategoryEditor = {};
categoryColDef ;
constructor()
{
this.getCategoryMapping();
this.createCategoryColDefinition();
}
ngOnInit() {
this.domLayout = "autoHeight";
}
onGridReady(params: any) {
params.api.sizeColumnsToFit();
params.api.resetRowHeights();
}
createCategoryColDefinition() {
this.categoryColDef = [
{
headerName: 'Is Subcategory', field: 'IsSubcategoryText', resizable: true,filter:true,
editable: function (params: any) {
return true;
},
cellEditor: "agSelectCellEditor",
cellEditorParams: {
values: this.extractValues(this.objCategoryEditor),
},
refData: this.objCategoryEditor,
}
]}
getCategoryMapping()
{
this.objCategoryEditor["0"] = "No";
this.objCategoryEditor["1"] = "Yes";
this.createCategoryColDefinition();
}
extractValues(mappings) {
return Object.keys(mappings);
}
}
当按“否”过滤时,它不返回任何行:-
当按 0 过滤时,它返回行:-
如何自定义过滤,以便在按“是”或“否”过滤时开始返回行? 请帮忙。
【问题讨论】:
-
我认为使用 agGrid-community 版本无法实现。这将通过 agSetColumnFilter 实现,它是 agGrid-Enterprise 的一部分并且是收费的。
标签: angular filtering ag-grid ag-grid-angular