【发布时间】:2020-09-04 01:08:27
【问题描述】:
我想显示一个包含按钮的覆盖容器。单击按钮时,应将事件传播到父组件。在我的研究中,我发现 有 设置“noRowsOverlayComponentParams”的选项在我的版本 (22.1.2) 中不存在。我也无法获取按钮的点击事件。
是否有解决我的问题的解决方法或设置?
PS:组件显示正确,但我无法获取点击事件。
网格选项:
let options: any = {
defaultColDef: {
sortable: true,
filter: true,
resizable: true
},
suppressPaginationPanel: true,
columnDefs: [...],
paginationPageSize: 10,
context: { componentParent: this},
domLayout: 'normal',
enableCellTextSelection: true,
autoSizePadding: 2,
noRowsOverlayComponent: 'myNoRowsComponent',
frameworkComponents: {
myNoRowsComponent: MyNoRowsComponent
}
};
MyNoRowsComponent.ts:
import { Component } from '@angular/core';
import { INoRowsOverlayAngularComp } from '@ag-grid-community/angular';
import { INoRowsOverlayParams, IAfterGuiAttachedParams } from '@ag-grid-enterprise/all-modules';
@Component({
selector: 'app-my-no-rows',
templateUrl: './my-no-rows.component.html',
styleUrls: ['./my-no-rows.component.scss']
})
export class MyNoRowsComponent implements INoRowsOverlayAngularComp {
params: any;
agInit(params: INoRowsOverlayParams): void {
this.params = params;
}
clickImport() {
// this.params.context.componentParent.clickButton(); // <-- here I want to emit an event
}
afterGuiAttached?(params?: IAfterGuiAttachedParams): void { }
}
MyNoRowsComponent.html:
<button (click)="clickImport()">My Button</Button>
【问题讨论】:
标签: angular typescript ag-grid ag-grid-angular