为什么 gridApi.onFilterChanged() 事件重定向页面
Why gridApi.onFilterChanged() event redirect the page
我有一个响应过滤功能的按钮
<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是对的,按钮的作用类似于提交表单而不是按钮
我有一个响应过滤功能的按钮
<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是对的,按钮的作用类似于提交表单而不是按钮