我在Angular 6应用程序中使用的是“ AG Grid”社区版。
我现在面临的挑战是:我有一个相当简单的数据结构,其中的一个列表绑定到网格上进行显示。基于其值,我想在网格中添加“操作”列,以使用户可以访问某些操作,例如删除条目,“升级”它等。
对于单独的数据绑定列,当绑定时,我会获得每一行的相应数据值,例如,可以使用单元格渲染器格式化显示。我希望能够与“动作”列(未绑定到该类的特定数据元素)做类似的事情-但看来我的“动作单元格渲染器”没有任何基础它的决定。
我有一个像这样的数据结构:
export interface Indicator {
Id: string;
Name: string;
IsGlobal: boolean;
}
Run Code Online (Sandbox Code Playgroud)
这些数组Indicators被绑定到OnInit我的Angular组件的功能中的AG网格。
我将AG网格的列定义为:
columnDefs = [
{ headerName: 'Name', field: 'Name', width: 200, editable: true },
{ headerName: 'Global', field: 'IsGlobal', editable: false, width: 100,
cellRenderer: (data) => {
// here, "data" refers to the "IsGlobal" value of the row being displayed
if (data.value === true) {
return 'Ja';
} else {
return 'Nein';
}
},
}, …Run Code Online (Sandbox Code Playgroud)