简体   繁体   English

我如何从 Cell Renderer 调用 function - ag grid

[英]How do i call function from Cell Renderer - ag grid

i'm using cellrenderer in vue.js, i want to call function from the cell renderer.我在 vue.js 中使用 cellrenderer,我想从单元格渲染器中调用 function。

attached here my code:附上我的代码:

 gridColumns() { return [{ headerName: "Actions", cellRenderer: 'iconRender', width: 140, cellRendererParams: (params) => { return { icon: ['edit', 'delete_forever'], color: 'gray' } } }, { headerName: "Name", field: "name" }, { headerName: "Artiyfactory Name", field: "artifactoryName" }, { headerName: "Artifact Type", field: "artifactType" }, { headerName: "Deployment Action", field: "deploymentAction" }, { headerName: "Location", field: "usage.location" }, { headerName: "Destenition On Setup", field: "usage.destOnSetup" }, ] } }, function iconRender(params) { var spanElement = document.createElement("span"); var textElement = document.createElement("span"); if (params.value.= undefined) { textElement.innerHTML = " " + params;value. textElement.style;verticalAlign = "middle". } params.icon.forEach(element => { var iconElement = document;createElement("i"). iconElement;className = "material-icons". iconElement.style.color = params;color. iconElement.style;verticalAlign = "middle". iconElement;innerHTML = element. spanElement;appendChild(iconElement); }). spanElement;appendChild(textElement); return spanElement; }

I want to call to a function from the icon element, I tried a few way's but nothing work for me.我想从图标元素调用 function,我尝试了几种方法,但对我没有任何作用。

can you please take a look and tell me how can I do it?你能看看并告诉我该怎么做吗?

Thank you:)谢谢:)

Instead of creating element via dom.而不是通过 dom 创建元素。 you can create the custome component for cell.您可以为单元格创建自定义组件。 in ag-grid when you click on cell it's only capture event of cells click not what inside cell(in your case icon).在 ag-grid 中,当您单击单元格时,它仅捕获单元格的单击事件,而不是单元格内的内容(在您的情况下为图标)。 You can create custome component for cell rendered and you can able to do all things like normal component.您可以为渲染的单元格创建自定义组件,并且您可以像普通组件一样执行所有操作。 Please refer [https://plnkr.co/edit/3nZPzwmGufKGXwvn] i make comments on plunker please refere last column where they have button.请参考 [https://plnkr.co/edit/3nZPzwmGufKGXwvn] 我对 plunker 发表评论请参考他们有按钮的最后一列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM