【发布时间】:2018-07-12 19:20:53
【问题描述】:
我有一个内联 cellRenderer 来修改单元格值,如下所示:
cellRenderer: function (params) {
if(params.value) {
return params.value * 100;
}
return '';
}
但是,当控件移出 cellRenderer 时,它会抛出以下异常:
ERROR TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at CellComp.push../node_modules/ag-grid/dist/lib/rendering/cellComp.js.CellComp.afterCellRendererCreated (cellComp.js:582)
at Promise.push../node_modules/ag-grid/dist/lib/utils.js.Promise.then (utils.js:1543)
at CellComp.push../node_modules/ag-grid/dist/lib/rendering/cellComp.js.CellComp.createCellRendererInstance (cellComp.js:564)
at CellComp.push../node_modules/ag-grid/dist/lib/rendering/cellComp.js.CellComp.attachCellRenderer (cellComp.js:589)
at CellComp.push../node_modules/ag-grid/dist/lib/rendering/cellComp.js.CellComp.afterAttached (cellComp.js:100)
at rowComp.js:938
at Array.forEach (<anonymous>)
at RowComp.push../node_modules/ag-grid/dist/lib/rendering/rowComp.js.RowComp.callAfterRowAttachedOnCells (rowComp.js:936)
at RowComp.push../node_modules/ag-grid/dist/lib/rendering/rowComp.js.RowComp.insertCellsIntoContainer (rowComp.js:554)
at RowComp.push../node_modules/ag-grid/dist/lib/rendering/rowComp.js.RowComp.refreshCellsInAnimationFrame (rowComp.js:460)
我还有很多其他这样的 cellRenderer 工作正常。不确定这个特定的有什么问题。例如下面一个工作得很好:
cellRenderer: function (params) {
return params.context.formatDate(params.data.createdDateTime);
}
我正在使用 "ag-grid-enterprise": "^16.0.0", 和 angular 6。
【问题讨论】:
-
奇怪....可能是它希望字符串返回?我已经在 ag-grid 上多次使用 cellRenderers,就像您在示例中那样,它工作正常.. 尝试 return ''+ params.value * 100
-
@Sh.Pavel 谢谢伙计,它奏效了。您节省了五月天!