我正在研究角度ag-grid。我正在尝试使用组单元格渲染器在单击加号时显示子网格数据。使用它时,我收到一个错误:Cell Renderer必须是String或Function。
var masterColumnDefs = [
// group cell renderer needed for expand / collapse icons
{field: 'name', cellRenderer: 'group'},
{field: 'account'},
{field: 'calls'},
{field: 'minutes', valueFormatter: "x.toLocaleString() + 'm'"}
];
var detailColumnDefs = [
{field: 'callId'},
{field: 'direction'},
{field: 'number'},
{field: 'duration', valueFormatter: "x.toLocaleString() + 's'"},
{field: 'switchCode'}
];
var detailGridOptions = {
columnDefs: detailColumnDefs,
onGridReady: function(params) {
params.api.sizeColumnsToFit();
}
};
var masterGridOptions = {
columnDefs: masterColumnDefs,
rowData: rowData,
masterDetail: true,
detailCellRendererParams: {
detailGridOptions: detailGridOptions,
getDetailRowData: function(params) {
params.successCallback(params.data.callRecords);
}
},
onGridReady: function(params) {
params.api.forEachNode(function (node) {
node.setExpanded(node.id === "1");
});
params.api.sizeColumnsToFit();
}
};
document.addEventListener('DOMContentLoaded', function() {
var gridDiv = document.querySelector('#myGrid');
new agGrid.Grid(gridDiv, masterGridOptions);
});
答案 0 :(得分:0)
您的名称列定义必须与此类似
{field: 'name', cellRenderer:'agGroupCellRenderer'}