【发布时间】:2021-11-30 10:38:54
【问题描述】:
我正在尝试包装 ColDef 定义,这样我可以比复制/粘贴应用程序中每个网格列的代码做得更好...
我当前的问题是我无法让 valueGetter 工作
//this is called from my angular COMPONENT to define the grid column
this.columnDefs.push(new AgColDef( 'Description').mycolDef());
mycolDef() : ColDef{
let myCD : ColDef {field : this.fieldName};
myCD.field = this.fieldName;
myCD.headerText = 'header ' + this.fieldName;
myCD.editable = true;
myCD.valueGetter = (function (params) {
return params.data.RevisionNumber; //this works. i can hard code the field
//return params.data[this.fieldName]; ///this does not work, the function does not know it belongs to an object?
});
return myCD;
};
这个想法是有一组类,这样我就可以为{日期、数字、列表值等}添加一列,所有的艰苦工作都已经完成、测试等......
有没有办法可以传入 valueSetter 函数,以便它识别它是对象的一部分?
【问题讨论】:
标签: typescript ag-grid-angular