首页 > 解决方案 > agGrid 汇总示例显示缺少 ClientSideRowModelModule

问题描述

我尝试执行 ag-grid 在其页面上显示的最小汇总示例。但无论如何,我不会让它工作。我得到的错误是:

ag-Grid: could not find matching row model for rowModelType clientSide
Row Model "Client Side" not found. Please ensure the ClientSideRowModelModule is loaded using: import '@ag-grid-community/client-side-row-model';

我尝试导入ClientSideRowModelModuleand ClientSideRowModel,如错误中所述,但这没有任何改变。

我尝试并逐步浏览了捆绑的代码,似乎 agggrid 无法访问他们自己的模块,尽管它们存在。

我把例子上传到了github,直接clone,npm i && npm run rullup然后打开index.html文件。 https://github.com/dennis-f/ag-grid-clientsiderowmodel-bug

git clone git@github.com:dennis-f/ag-grid-clientsiderowmodel-bug.git
npm i && npm run rollup

标签: javascriptag-gridrollup

解决方案


好的,我设法让它工作。

老的:

import {Grid} from '@ag-grid-community/all-modules';

新的:

import {AllCommunityModules, Grid, ModuleRegistry} from '@ag-grid-community/all-modules';
ModuleRegistry.registerModules(AllCommunityModules);

我不知道为什么在所有这些示例中都缺少此功能,但是即使您使用 ' all-modules' 包,您也需要手动注册模块。

它不知道所有模块都应该在启动时加载。这是一个很好的解决方案,但不幸的是它只在这里解释。

而不是AllCommunityModules你显然可以只加载你真正需要的那些。


推荐阅读