【发布时间】:2020-07-19 18:11:21
【问题描述】:
我正在尝试在“Ag 网格”中添加一个新行。
我将它保存在数据库中,问题是在视觉上该行被添加到“Ag网格”但它显示为空。
这是点击事件和添加行的代码。
this.gridOptions.api.updateRowData({ add: [form.form.value] });
这是变量“gridOptions”:
this.gridOptions = {
context: { componentParent: this },
defaultColDef: {
resizable: true,
},
rowSelection: 'multiple'
};
对象“form.form.value”包含以下内容:
{CodPersona: "001", Nombre: "John", Descripcion: "John", Fecha: "2020-04-07"}
这是“Ag网格”的html代码:
<ag-grid-angular class="ag-theme-material"
[rowData]="rowData"
[columnDefs]="columnDefs"
[gridOptions]="gridOptions"
></ag-grid-angular>
数据库表包含以下字段:
IdPersona, CodPersona, Nombre, Descripcion, Fecha
这是浏览器中的结果截图:
注意:rowData 我使用服务在“ngInit”事件中加载它,谢谢。
【问题讨论】:
-
您能否提供有关您的解决方案的更多详细信息(更多代码甚至通过 stackblitz 或 plinker 提供的完整示例),这样检查和帮助会更简单
-
解决方案是自定义传递给updateRowData(行)的对象类型,它传递的是NgForm类型的对象“form.form.value”,谢谢