Angular 6 Ag

编程入门 行业动态 更新时间:2024-10-27 22:22:22
本文介绍了Angular 6 Ag-grid单元格渲染器单击功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我正在尝试设置ag-grid,但我做不到一件事.我想有一列动作.然后,我希望它有一个链接或按钮来触发组件文件中的方法.

So I'm trying to setup ag-grid and I can't get one thing to work. I want to have a column that is actions. Then I want it to have a link or button that triggers a method in the component file.

对于列def,我有以下内容.我在做什么错了?

For the column def I have the following. What am I doing wrong?

{ headerName: 'Actions', cellRenderer: params => { return `<a (click)="onEditClick("${params.data.hostname}")">Edit</a>`; } }

推荐答案

我使用cellRenderFramework:

I use cellRenderFramework:

{ headerName: '', width: 30, cellRendererFramework: ActionCellRendererComponent, cellRendererParams: { icon: 'fa-download', action: this.downloadAttachmentAction } }

并且我有自定义组件

@Component({ selector: 'cu-download-link-cell-renderer', template: ` <div class="text-center"> <i class="fa {{params.icon}}" (click)="onClick()" aria-hidden="true"></i> </div>` }) export class ActionCellRendererComponent { params; constructor() { } agInit(params): void { this.params = params; if (_.isNil(params.action)) { throw new Error('Missing action parameter for ActionCellRendererComponent'); } } onClick(): void { this.params.action(this.params); } } export type CellAction = (params) => void;

更多推荐

Angular 6 Ag

本文发布于:2023-11-22 21:14:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619033.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Angular   Ag

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!