在ag-grid中编辑单元格值后如何启动方法? [英] How to launch a method after a cell value has been edited in ag-grid?

查看:634
本文介绍了在ag-grid中编辑单元格值后如何启动方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的专栏:

I have this simple column:

这里是其定义:

{
      headerName: "Activité",
      field: "activite",
      editable: true,
       , cellClass: "cell-wrap-text"
      }  

我想在用户每次在该列中输入新输入时启动的方法。

Here's the method I want to launch every time the user enters a new input in that column.

  public UpdateActValue() {
      this.data.sendActToBia(this.params.data.activite);
      }  

这是我的问题:

1 /有
2 /是否应该简单地定义一个自定义单元格渲染器并在那里做所有必要的工作? br>
谢谢!

Here are my questions:
1/ Are there any ag-grid "native" way to launch a particular method after a cell value from a column has been edited?
2/ Should I simply define a custom cell renderer and do all the necessary work there?
Thank you!

推荐答案

您可以使用 cellValueChanged 事件绑定以检测单元格值的变化。

You can make use of the cellValueChanged event binding to detect changes in cell value.

在component.html上,您只需绑定 onCellValueChanged() cellValueChanged 事件的code>方法。

On your component.html, you can simply bind the onCellValueChanged() method to the cellValueChanged event.

<ag-grid-angular 
.
.
(gridReady)="onGridReady($event)"
(cellValueChanged)="onCellValueChanged($event)"
>

然后在component.ts上,定义 onCellValueChanged()方法,每当任何单元格值发生更改时都会触发。

And on your component.ts, you will define the onCellValueChanged() method, which will be fired every single time any cell value has changed.

onCellValueChanged(event) {
  // handle the rest here
}

您可能会读到更多有关

You may read up more about grid cell editing and change detection over here.

这篇关于在ag-grid中编辑单元格值后如何启动方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆