我在角度 7 上测试 ag-grid。我想做的一件事是检测网格中的单元格变化,但我无法触发 onCellValueChanged()。我只是在 js 和 angular 中迈出第一步,所以也许这是一个愚蠢的问题。谢谢
我在 app.component.html 中的网格定义:
<ag-grid-angular style="width: 950px; height: 320px;" class="ag-theme-balham"
[enableSorting]="true" [enableFilter]="true"
[rowData]="stocks" [columnDefs]="columnDefs" rowSelection="multiple"
[enterMovesDownAfterEdit]="true"
[enterMovesDown]="true">
(cellValueChanged)="onCellValueChanged($event)"
</ag-grid-angular>
我的 app.component.ts:
import { Component , OnInit} from '@angular/core';
import { StockService } from './stock.service';
import { stock } from './stock';
import {MatButtonModule, MatCheckboxModule} from '@angular/material';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
stocks: stock[];
public loading = false;
pedidos: stock[];
constructor(private stockService: StockService) {this.stocks = []; }
columnDefs = [
{headerName: 'Código',
field: 'cod_ins',
width: 150,
suppressSizeToFit: true
},
{headerName: 'Cantidad',
field: 'pedido',
width: 110,
editable: true,
type: 'numericColumn',
}
];
onCellValueChanged(params: any) {
console.log('Estoy en onCellValueChanged !!!');
}
}