如何在 Syncfusion Grid 中过滤时禁用自动完成功能
我试过这个:
actionBegin(args) {
if (args.requestType === 'filtering' && args.currentFilterObject.value == null) {
const filterPopup = document.getElementsByClassName('e-filter-popup')[0];
const autoCompleteInput = filterPopup.querySelector('.e-autocomplete') as HTMLInputElement;
// Check if the autoCompleteInput is available
if (autoCompleteInput) {
const filterValue = autoCompleteInput.value;
// Set the filter value for the current filter object
args.currentFilterObject.value = filterValue;
// Set the filter value for the column in the arguments
args.columns.forEach((column) => {
if (column.field === args.currentFilteringColumn) {
column.value = filterValue;
console.log(column);
}
});
}
}
}
要禁用自动完成,您可以使用 beforeCustomFilterOpen 内部事件。将 AutoComplete 控件的 autofill 属性设置为 false,以防止自定义筛选器中的自动完成操作。此外,您可以使用 CSS 来隐藏建议下拉列表。请参考下面的代码片段和示例:
[app.component.css]
.e-ddl.e-popup.e-popup-flmenu.e-lib.e-control.e-popup-open {
display: none;
}
[app.component.ts]
created() {
(this.grid as any).on('beforeCustomFilterOpen', () => {
(
this.grid as any
).filterModule.filterModule.excelFilterBase.dlgObj.element
.querySelectorAll('.e-autocomplete')
.forEach((input: any) => {
(
input.parentElement.querySelector('.e-clear-icon') as HTMLElement
).classList.add('e-clear-icon-hide');
input.ej2_instances[0].autofill = false;
});
});
}
示例:https://stackblitz.com/edit/angular-grid-filter-disable-autofill