gpt4 book ai didi

javascript - 使用 Ag-Grid Enterprise 许可证获取 'ag-grid: Looking for component [agSetColumnFilter] but it wasn' t 找到。”错误

转载 作者:行者123 更新时间:2023-11-30 06:18:42 25 4
gpt4 key购买 nike

几个月来,我一直在使用 Ag-Grid 的企业功能“agSetColumnFilter”,没有出现任何问题。

我正在使用以下版本:

    "ag-grid": "^17.1.1",
"ag-grid-enterprise": "^17.1.1",
"ag-grid-react": "^17.1.0",

经过一些重构后,我在单击过滤器菜单后开始出现此错误:

ag-grid: Looking for component [agSetColumnFilter] but it wasn't found.
Array.concat.ComponentProvider.retrieve @ componentProvider.js?6ebb:209
Array.concat.ComponentResolver.resolveByName @ componentResolver.js?1587:159
Array.concat.ComponentResolver.getComponentToUse @ componentResolver.js?1587:155
Array.concat.ComponentResolver.newAgGridComponent @ componentResolver.js?1587:271
Array.concat.ComponentResolver.createAgGridComponent @ componentResolver.js?1587:236
Array.concat.FilterManager.createFilterInstance @ filterManager.js?d1c0:376
Array.concat.FilterManager.createFilterWrapper @ filterManager.js?d1c0:393
Array.concat.FilterManager.getOrCreateFilterWrapper @ filterManager.js?d1c0:343
Array.concat.StandardMenuFactory.showPopup @ standardMenu.js?505d:52
Array.concat.StandardMenuFactory.showMenuAfterButtonClick @ standardMenu.js?505d:45
Array.concat.HeaderComp.showMenu @ headerComp.js?f669:122
(anonymous) @ headerComp.js?f669:107
componentResolver.js?1587:274 Error creating component filter=>agTextColumnFilter
Array.concat.ComponentResolver.newAgGridComponent @ componentResolver.js?1587:274
Array.concat.ComponentResolver.createAgGridComponent @ componentResolver.js?1587:236
Array.concat.FilterManager.createFilterInstance @ filterManager.js?d1c0:376
Array.concat.FilterManager.createFilterWrapper @ filterManager.js?d1c0:393
Array.concat.FilterManager.getOrCreateFilterWrapper @ filterManager.js?d1c0:343
Array.concat.StandardMenuFactory.showPopup @ standardMenu.js?505d:52
Array.concat.StandardMenuFactory.showMenuAfterButtonClick @ standardMenu.js?505d:45
Array.concat.HeaderComp.showMenu @ headerComp.js?f669:122
(anonymous) @ headerComp.js?f669:107
filterManager.js?d1c0:401 Uncaught TypeError: Cannot read property 'then' of null
at FilterManager.Array.concat.FilterManager.putIntoGui (filterManager.js?d1c0:401)
at FilterManager.Array.concat.FilterManager.createFilterWrapper (filterManager.js?d1c0:394)
at FilterManager.Array.concat.FilterManager.getOrCreateFilterWrapper (filterManager.js?d1c0:343)
at StandardMenuFactory.Array.concat.StandardMenuFactory.showPopup (standardMenu.js?505d:52)
at StandardMenuFactory.Array.concat.StandardMenuFactory.showMenuAfterButtonClick (standardMenu.js?505d:45)
at HeaderComp.Array.concat.HeaderComp.showMenu (headerComp.js?f669:122)
at HTMLSpanElement.<anonymous> (headerComp.js?f669:107)

我所做的重构工作是迭代数组并创建 React-Bootstrap 选项卡组件,这些组件在单击时呈现 Ag-grid 组件。我将选项卡数组放在要呈现的 <div> 中。

对于我的行数据,它是一个像这样的数组:

[{
id: 1,
keyword: 'tv',
projects: [{ id: 1, name: 'Project 1' }, {id: 2, name: 'Project 2' }]
},
{
id: 2,
keyword: 'sofa',
projects: [{ id: 3, name: 'Project 3' }]
}]

我的列定义是从这样的函数返回的:( lookup 是存储我的过滤器选项的散列,我迭代这些值并生成一个字符串数组以提供给 filterParams.values :

function createColumnDefs = (lookup) => ([
{
field: 'projects',
headerName: 'Projects',
filter: 'agSetColumnFilter',
cellRenderer: 'ListRenderer',
cellRendererParams: {
accessor: 'name'
},
filterParams: {
values: _.get(lookup, 'projects', []).map(project => project.name),
debounceMs: 200
}
},
{
field: 'keyword',
headerName: 'Keyword',
filter: 'agTextColumnFilter',
sort: 'asc',
filterParams: {
debounceMs: 200
},
pinned: 'left',
minWidth: 250
}
]);

一切正常,包括显示行、行选择、排序、文本过滤、无限滚动。仅当我单击列标题中的过滤器汉堡包菜单时,才会出现上述错误。

这个过滤器在过去一直有效,从那时起我就没有改变行数据结构或我的列定义或过滤器选项。

*************** 截图供引用***************

My row data (an array of objects Column Defs that I pass into Ag-grid

error printed in Chrome inspector

最佳答案

我解决了这个问题

  • 正在运行 npm i @ag-grid-enterprise/set-filter ,

  • 在使用设置过滤器的组件中导入模块:import { SetFilterModule } from '@ag-grid-enterprise/set-filter';

  • 添加 SetFilterModule到网格模块数组:

    gridModules = [ClientSideRowModelModule, RowGroupingModule, MenuModule, SetFilterModule];

  • 当然还有将 gridModules 绑定(bind)到网格(我之前有):<ag-grid-angular... [modules]="gridModules"></ag-grid-angular>

我通过检查 https://www.ag-grid.com/javascript-grid-filter-set/ 上第一个示例中的代码得到了这个解决方案

关于javascript - 使用 Ag-Grid Enterprise 许可证获取 'ag-grid: Looking for component [agSetColumnFilter] but it wasn' t 找到。”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54659659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com