在Angular上安装Ag-Grid-Enterprise时出错

时间:2019-06-25 14:50:34

标签: angular ag-grid ag-grid-angular

我尝试在7.3.3上安装ag-grid-enterprise。我用它来安装许可证:https://www.ag-grid.com/javascript-grid-set-license/

现在,当我编译代码时,它给了我这个错误:


ERROR in node_modules/ag-grid-enterprise/dist/lib/rangeController.d.ts(2,10): er                                                             ror TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/a                                                             g-grid-community/main"' has no exported member 'CellPosition'.
node_modules/ag-grid-enterprise/dist/lib/rangeController.d.ts(2,81): error TS230                                                             5: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/ag-grid-co                                                             mmunity/main"' has no exported member 'CellRangeParams'.
node_modules/ag-grid-enterprise/dist/lib/rangeController.d.ts(2,98): error TS230                                                             5: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/ag-grid-co                                                             mmunity/main"' has no exported member 'CellRange'.
node_modules/ag-grid-enterprise/dist/lib/rangeController.d.ts(2,109): error TS23                                                             05: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/ag-grid-c                                                             ommunity/main"' has no exported member 'RowPosition'.
node_modules/ag-grid-enterprise/dist/lib/rangeController.d.ts(3,22): error TS242                                                             0: Class 'RangeController' incorrectly implements interface 'IRangeController'.
  Property 'clearSelection' is missing in type 'RangeController'.
node_modules/ag-grid-enterprise/dist/lib/setFilter/setFilter.d.ts(2,10): error T                                                             S2305: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/ag-gri                                                             d-community/main"' has no exported member 'ProvidedFilter'.
node_modules/ag-grid-enterprise/dist/lib/setFilter/setFilterModel.d.ts(2,10): er                                                             ror TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-webapp/node_modules/a                                                             g-grid-community/main"' has no exported member 'ProvidedFilterModel'.
node_modules/ag-grid-enterprise/dist/lib/widgets/selection/abstractSelectionHand                                                             le.d.ts(2,117): error TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-web                                                             app/node_modules/ag-grid-community/main"' has no exported member 'CellRange'.
node_modules/ag-grid-enterprise/dist/lib/widgets/selection/abstractSelectionHand                                                             le.d.ts(2,128): error TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-web                                                             app/node_modules/ag-grid-community/main"' has no exported member 'RowPosition'.
node_modules/ag-grid-enterprise/dist/lib/widgets/selection/abstractSelectionHand                                                             le.d.ts(2,141): error TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-web                                                             app/node_modules/ag-grid-community/main"' has no exported member 'CellPosition'.
node_modules/ag-grid-enterprise/dist/lib/widgets/selection/abstractSelectionHand                                                             le.d.ts(2,155): error TS2305: Module '"C:/Users/kb60500/fusion-portal/fusion-web                                                             app/node_modules/ag-grid-community/main"' has no exported member 'ISelectionHand                                                             le'.

这是我的package.json

"dependencies": {
...
"ag-grid": "^18.1.2",
    "ag-grid-angular": "^20.2.0",
    "ag-grid-community": "^20.2.0",
    "ag-grid-enterprise": "^21.0.1"
}

我已经将其导入了app.module.ts

import { AgGridModule } from 'ag-grid-angular';

还使用以下命令将其导入组件im中:

import "ag-grid-enterprise";
import { GridApi, Grid, GridOptions } from 'ag-grid-community';
import { AgGridModule } from 'ag-grid-angular'; 

2 个答案:

答案 0 :(得分:0)

在您的main.ts文件上(通常与index.html,manifest.json,styles.scss等位于同一目录级别),您将需要设置许可证密钥。我不确定您是否已完成操作,但是您应该去检查一下。

import { LicenseManager } from 'ag-grid-enterprise'; // ag-grid license

.
.
.

// set ag-grid license
LicenseManager.setLicenseKey('YOURLICENSE');

此外,在您的component.ts上,导入这些模块就足够了。无需重新导入AgGridModule,因为它已经被导入到模块中了。

import { GridApi, Grid, GridOptions } from 'ag-grid-community';

答案 1 :(得分:0)

我的问题是,ag-grid-community和ag-grid-enterprise的版本不相同。一旦更改了版本,它便开始工作。