我刚刚下载了ag-grid并将其正确引用到我的网页中。遵循ag-grid网站上列出的JavaScript示例。
我收到错误'无法设置属性' cellRendererMap' of null' 仅供参考 - 我没有使用任何MVC框架。
<pre>
<html>
<h1> My new Page </h1>
<body>
<span> Hi I am a rockstar </span>
<div id="newGrid" style="height: 100%;width:500px;"></div>
<script type="text/javascript" src="/rsportal/js/ag-grid/dist/ag-grid.min.js"></script>
<script type="text/javascript">
var columnDefs = [
{headerName: "Make", field: "make"},
{headerName: "Model", field: "model"},
{headerName: "Price", field: "price"}
];
var rowData = [
{make: "Toyota", model: "Celica", price: 35000},
{make: "Ford", model: "Mondeo", price: 32000},
{make: "Porsche", model: "Boxter", price: 72000}
];
var gridOptions = {
columnDefs: columnDefs,
rowData: rowData
};
document.addEventListener("DOMContentLoaded", function() {
var eGridDiv = document.querySelector('#newGrid');
new agGrid.Grid(eGridDiv, gridOptions);
});
</script>
</body>
</html>
</pre>
答案 0 :(得分:1)
您是否尝试删除DOMContentLoaded处理程序? 当DOM准备就绪时,您的脚本已经执行。
providers
答案 1 :(得分:0)
谢谢Berangar。 class =“ag-fresh”解决了这个问题。