【问题标题】:Ag-grid-enterprise: TypeError: details.rootNode.updateHasChildren is not functionAg-grid-enterprise:TypeError:details.rootNode.updateHasChildren 不起作用
【发布时间】:2021-01-03 07:15:47
【问题描述】:

我正在使用 Angular 9,并且我已经安装了所有必要的 ag-grid 包。

包.json:

"ag-grid-angular": "^23.1.1",
"ag-grid-community": "^23.1.1",
"ag-grid-enterprise": "^24.0.0"

对于 ag-grid-enterprise,我已添加许可证并将其导入 main.ts

main.ts

// other imports...

import {LicenseManager} from "ag-grid-enterprise";
LicenseManager.setLicenseKey("license key");

// bootstrap your angular application. ie: platformBrowser().bootstrapModuleFactory(..)

并在app模块中导入ag-grid-enterprise并将样式也导入到style.scss中

import 'ag-grid-enterprise';

import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-alpine.css';

我也尝试过显示 RowGrouping 表和简单表。请在下面找到一些示例代码 html:

<ag-grid-angular
style="width: 500px; height: 150px;"
class="ag-theme-alpine"
[rowData]="rowData"
[columnDefs]="columnDefs">
</ag-grid-angular>

ts:

   import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.scss' ]
})
export class AppComponent  {

    columnDefs = [
        {field: 'make' },
        {field: 'model' },
        {field: 'price'}
    ];

    rowData = [
        { make: 'Toyota', model: 'Celica', price: 35000 },
        { make: 'Ford', model: 'Mondeo', price: 32000 },
        { make: 'Porsche', model: 'Boxter', price: 72000 }
    ];

}

将应用程序启动到浏览器时,我遇到了错误并且表格未加载。另请找到截图以供参考。

TypeError: details.rootNode.updateHasChildren is not function

【问题讨论】:

  • 为什么要同时导入社区版和企业版?

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


【解决方案1】:

您发送的所有代码看起来都很好,唯一看起来奇怪的是您的package.json

您应该保持所有版本一致,即如果使用 v23.1.1,则 ag-grid-commmunityag-grid-enterpriseag-grid-angular 必须都是 v23.1.1。

我会把 package.json 改成这个,看看有没有帮助:

"ag-grid-angular": "^23.1.1",
"ag-grid-community": "^23.1.1",
"ag-grid-enterprise": "^23.1.1"

【讨论】:

    猜你喜欢
    • 2021-02-09
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多