我目前正在尝试在 agGrid 标头中添加一个角度指令。为此,我在 headerCellRenderer 中传递了一个函数,如下所示:
我的网格选项:
this.columnDefs = [
{headerName: "Height", field: "rowHeight"},
{headerName: "Athlete", field: "athlete", width: 180},
{headerName: "Age", field: "age", width: 90},
{headerName: "Country", field: "country", width: 120},
{headerName: "Year", field: "year", width: 90}
];
this.gridOptions = {
columnDefs: this.columnDefs,
rowData: null,
//enableSorting: true,
headerHeight: 60,
//enableFilter: true,
enableColResize: true,
angularCompileRows:true,
angularCompileHeaders: true,
headerCellRenderer: (params) =>
{return this.headerCellRendererFunc(params);},
rowSelection: 'multiple',
};
我的功能定义如下:
headerCellRendererFunc(params) {
const headerColDef = params.colDef;
headerColDef.name = headerColDef.headerName;
headerColDef.isMetadata = false;
return '<header column="headerColDef"></header>';
}
结果我的指令被渲染但“列”绑定是空的,我不明白我必须如何将对象传递给我的指令。
有任何想法吗 ?谢谢 !