为什么gridApi.onFilterChanged()事件会重定向页面



我有一个按钮来响应过滤器功能

<div class="col-md-1">
<button (click)="applyFilter()" class="btn btn-primary"
style="float: right;">Search</button>                     
</div>    

applyFilter() {
this.gridApi.onFilterChanged();
}
isExternalFilterPresent(): boolean {
return true;
}
doesExternalFilterPass(node: RowNode): boolean {
return true;
}
constructor(private http: HttpClient, private _snackBar: MatSnackBar) {
this.gridOptions = {
editType: 'fullRow',
columnDefs: this.columnDefs,
pagination: true,
animateRows: true,
isExternalFilterPresent: this.isExternalFilterPresent.bind(this),
doesExternalFilterPass: this.doesExternalFilterPass.bind(this),
};
}
<ag-grid-angular style="width: 100%; height:600px;" class="ag-theme-alpine"
[defaultColDef]="defaultColDef"
rowSelection='single' [gridOptions]="gridOptions"
(rowValueChanged)="onRowChanged($event)" (gridReady)="onGridReady($event)">
</ag-grid-angular>

ag-Grid的非常基本的外部过滤器实现

然而,当点击搜索按钮,整个页面直接到前一页,这是非常奇怪的,我无法调试。

我不确定这是否是解决问题的最佳方法,但我通过将false返回到applyFilter()来使其工作

applyFilter() {
this.gridApi.onFilterChanged();
return false;   /// yea that fix it...
}

所以@nullptr。T是正确的,按钮的行为就像提交表单而不是按钮

最新更新