简体   繁体   English

Ag-Grid 行组呈现错误

[英]Ag-Grid row groups rendering bug

I'm only grouping rows on certain values.我只是根据某些值对行进行分组。 Here's a simplified version of my database structure:这是我的数据库结构的简化版本:

  • item物品
    • id ID
    • parent ID (if this is a child item)父 ID(如果这是子项)
    • item type (parent, child, normal)项目类型(父、子、普通)

I am grouping when the row's item type is parent.当行的项目类型为父项时,我正在分组。 I do a database fetch for that row's children, and populate them in the row group.我为该行的子项执行数据库提取,并将它们填充到行组中。

I end up with a very strange rendering problem: (GIF) https://imgur.com/a/8lFVjLn我最终遇到了一个非常奇怪的渲染问题:(GIF) https://imgur.com/a/8lFVjLn

Here is my code.这是我的代码。 It's CoffeeScript but should be self-explanatory for those familiar with JS.它是 CoffeeScript,但对于那些熟悉 JS 的人来说应该是不言自明的。 "?" “?” is just a null check, "@" is "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 is populated in @gridLoadChildren . @childWorks填充在@gridLoadChildren Other than that, @gridLoadChildren is just a database call that performs a select using the parent ID.除此之外, @gridLoadChildren只是一个使用父 ID 执行select的数据库调用。

Unfortunately for what I want I could not use Ag Grid's row grouping.不幸的是,我无法使用 Ag Grid 的行分组。 The whole time I was working on this feature it felt like I was wrestling with the grid and trying to make it do something it wasn't meant to do.在我开发这个功能的整个过程中,感觉就像我在与网格搏斗并试图让它做一些它不应该做的事情。 Thankfully, I came across the master/detail documentation and will be going that route instead.谢天谢地,我遇到了主/详细文档,并将改为走这条路。 So far it works exactly for what I need (server side data and only expanding groups for certain rows).到目前为止,它完全适用于我所需要的(服务器端数据和仅扩展某些行的组)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM