angular - 无法通过单元格渲染器选项调用 agGrid(Angular2) 中的服务

标签 angular ag-grid

我正在使用 ag-Grid 来显示用户列表。如果我编辑用户详细信息,那么我想单击网格中的更新按钮来编辑相应的用户详细信息。

这是 ag_grid 中的列标题

 { headerName: 'Update', field: "update", width: 80, cellRenderer:this.updateRenderFunction}      

我正在使用单元格渲染器

updateRenderFunction(params){
   var eSpan = document.createElement('button');
   eSpan.innerHTML = "Update";
    var data = params.node.data;

   eSpan.addEventListener('click',()=>{
                       //here i want to call service

  })

  return eSpan;

 }

最佳答案

试试这个对我有用...像下面这样在 updateRenderFunction 之后给 bind(this)。

{ headerName: 'Update', field: "update", width: 80, cellRenderer:this.updateRenderFunction.bind(this)} 

关于angular - 无法通过单元格渲染器选项调用 agGrid(Angular2) 中的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37811677/

相关文章:

javascript - ag-grid 服务器端分页独立设置最后一行

angular - ag-param() 在 ag-register-params 之前调用

angular - 找不到与@babel/helper-validator-identifier@^7.9.5 匹配的版本

angular - 如何用switchMap取消http请求?

html - 如何增加 Angular Material 中 mat-select 表单的宽度?

angular - 在 Angular 6 上设置自动刷新页面

sorting - AG-Grid 排序不适用于 TreeData

angular - Aggrid 创建显示特定组值的列

angular - 如何以 Angular react 形式保持值(value)?

angularjs - Ag-grid 自定义过滤器 : filterParams - cellRenderer in Angular 1. x