在我的角度应用程序中,我有一个UI-Grid和一个用于打开模态窗口的按钮。 在我的网格选项中,我启用了外部过滤。但问题是每当我进入过滤器字段并按下输入按钮(模态窗口)被触发并且模态打开。我的控制器里面没有任何关键事件。
以下是ui-grid的网格选项:
gridOptions: uiGrid.IGridOptionsOf<any> = {
appScopeProvider: this,
data: [] as any[],
enableFiltering: true,
enablePaginationControls: false,
useExternalPagination: true,
minRowsToShow: 5,
useExternalSorting: true,
useExternalFiltering: true,
onRegisterApi: (gridApi: uiGrid.IGridApiOf<any>) => {
this.gridApi = gridApi;
this.gridApi.core.on.sortChanged(this.$scope, (grid: uiGrid.IGridInstanceOf<any>, columns: Array<uiGrid.IGridColumnOf<any>>) => this.sortRequests(grid, columns));
this.gridApi.pagination.on.paginationChanged(this.$scope, (newPage: number, pageSize: number) => this.changePage(newPage, pageSize));
this.gridApi.core.on.filterChanged(this.$scope, () => {
if (this.filterTimeout != undefined) {
this.$timeout.cancel(this.filterTimeout);
}
this.filterTimeout = this.$timeout(() => this.filterRequests(), 500);
});
},
我已经在过滤器方法中设置了调试器,但只有在键入字符时按Enter键才会触发。
有人知道按下Enter键时触发此按钮的内容是什么?
更新1
<button class="btn btn-primary" ng-click="vm.open()" translate="country.headers.selectCountry"></button>
<div id="grid1" ui-grid="vm.gridOptions" ui-grid-pagination></div>
open() {
let instance = this.$uibModal.open({
templateUrl: 'app/common/controllers/html.html',
controller: 'controller as vm',
backdrop: 'static',
windowClass: 'country-modal',
resolve: {
programId: () => this.$stateParams['programId']
}
});
instance.result.then((dataGenerated: boolean) => {
if (dataGenerated) {
this.loadData();
}
});
}
更新2:
private filterRequests(): void {
let grid = this.gridApi.grid;
this.filtering = [];
for (let i = 0; i < grid.columns.length; i++) {
let column = grid.columns[i];
if (column.filters.length > 0) {
for (let j = 0; j < column.filters.length; j++) {
let filter = column.filters[j].term;
if (filter != undefined && filter != '')
this.filtering.push(column.field + '.contains("' + filter + '")');
}
}
}
this.loadRequests();
}
loadRequests(): void {
this.service
.get(
this.model.id,
{
params: {
page: this.pagingInfo.page,
pageSize: this.pagingInfo.pageSize,
sort: this.sorting,
filter: this.filtering
}
})
.then((data: any) => {
this.gridOptions.data = data.data;
this.gridHeight = (this.gridOptions.data.length + 2) * this.gridOptions.rowHeight;
this.pagingInfo.page = data.page;
this.pagingInfo.pageSize = data.pageSize;
this.pagingInfo.totalCount = data.totalCount;
});
}
各种问候,布伦特