Ag-Grid 行组渲染错误
Ag-Grid row groups rendering bug
我只是根据某些值对行进行分组。这是我的数据库结构的简化版本:
- 项目
- id
- 父项 ID(如果这是子项)
- 项目类型(父项、子项、普通)
当行的项类型是父项时,我正在分组。我为该行的子项执行数据库提取,并将它们填充到行组中。
我遇到了一个非常奇怪的渲染问题:
(GIF) https://imgur.com/a/8lFVjLn
这是我的代码。它是 CoffeeScript,但对于熟悉 JS 的人来说应该是不言自明的。 “?”只是空检查,“@”是 "this"
....
# the user has expanded a group, so check that we have parent node data...
else if params.parentNode? and params.parentNode.data? and params.parentNode.expanded
parentId = params.parentNode.data.id
if @editionsDict[parentId]?
params.successCallback(@editionsDict[parentId], @editionsDict[parentId].length)
else
# database call that returns a promise for when data is retrieved
@gridLoadChildren(parentId).then((res) =>
setTimeout(()=>
@editionsDict[parentId] = @childWorks
params.successCallback(@editionsDict[parentId], @editionsDict[parentId].length)
,0)
)
@childWorks
填充在 @gridLoadChildren
中。除此之外,@gridLoadChildren
只是一个使用父 ID 执行 select
的数据库调用。
不幸的是,我无法使用 Ag Grid 的行分组。在我处理此功能的整个过程中,感觉就像我在与网格搏斗并试图让它做一些它不应该做的事情。值得庆幸的是,我看到了 master/detail 文档,并将改用那条路线。到目前为止,它完全符合我的需要(服务器端数据和仅针对某些行扩展组)。
我只是根据某些值对行进行分组。这是我的数据库结构的简化版本:
- 项目
- id
- 父项 ID(如果这是子项)
- 项目类型(父项、子项、普通)
当行的项类型是父项时,我正在分组。我为该行的子项执行数据库提取,并将它们填充到行组中。
我遇到了一个非常奇怪的渲染问题: (GIF) https://imgur.com/a/8lFVjLn
这是我的代码。它是 CoffeeScript,但对于熟悉 JS 的人来说应该是不言自明的。 “?”只是空检查,“@”是 "this"
....
# the user has expanded a group, so check that we have parent node data...
else if params.parentNode? and params.parentNode.data? and params.parentNode.expanded
parentId = params.parentNode.data.id
if @editionsDict[parentId]?
params.successCallback(@editionsDict[parentId], @editionsDict[parentId].length)
else
# database call that returns a promise for when data is retrieved
@gridLoadChildren(parentId).then((res) =>
setTimeout(()=>
@editionsDict[parentId] = @childWorks
params.successCallback(@editionsDict[parentId], @editionsDict[parentId].length)
,0)
)
@childWorks
填充在 @gridLoadChildren
中。除此之外,@gridLoadChildren
只是一个使用父 ID 执行 select
的数据库调用。
不幸的是,我无法使用 Ag Grid 的行分组。在我处理此功能的整个过程中,感觉就像我在与网格搏斗并试图让它做一些它不应该做的事情。值得庆幸的是,我看到了 master/detail 文档,并将改用那条路线。到目前为止,它完全符合我的需要(服务器端数据和仅针对某些行扩展组)。