想要在单击详细信息图标时打开一个垫对话框。但是问题是“ this”不是指类。它指的是当前网格。
constructor(private dialog: MatDialog) {}
ngOnInit() {
this.gridOptions = <GridOptions>{
rowSelection: 'multiple',
floatingFilter: true
};
this.gridOptions.columnDefs = [
{
headerName: 'Detail', field: '', filter: false, width: 80,
sortable: false,
onCellClicked: this.openModal,
cellRenderer: (data) => {
return `<mat-icon class="mat-icon material-icons" style="cursor:pointer;" aria-hidden="true">
keyboard_capslock</mat-icon>`;
}
},
{ headerName: 'Field Name', field: 'fieldName'}
];
openModal(row): void {
const detailRef = this.dialog.open(DetailComponent, {
height: '100vw',
width: '80vh',
direction: 'ltr',
data: {
record: row.data
}
});
错误:无法获取未定义或空引用的属性“ open”
这里是指Grid,而不是类。
如何引用类方法打开对话框?
感谢所有帮助和建议。
谢谢
答案 0 :(得分:1)
内联cellRenderer
仅可用于简单情况。
如果需要使用内部函数或连接到第三方库,则必须将其编写为custom cell renderer component。