Slickgrid 对层次结构进行排序

Slickgrid sorting a hierarchy

我创建了一个只有 2 层的 slickgrid 层次结构。层次结构的实现遵循示例 5 (https://6pac.github.io/SlickGrid/examples/example5-collapsing.html). I am using the following fork - http://6pac.github.io/SlickGrid。我只想按第一级排序,并让子项按相同的顺序排列。我尝试将可排序的 属性 添加到列中,但是什么都没做。关于如何执行此操作的任何指示,我都不知道从哪里开始。一如既往,非常感谢。

关于您引用的示例,有几点需要注意。

  1. 在该示例中,您需要自己对数据进行排序,简而言之,这意味着您必须添加自己的排序函数,并且最终必须创建大量递归函数(因为分层数据只能通过递归排序)
  2. 让 pre-built 来做那种工作会更好,因为我也需要它,所以我开始了一项功能更改,最终将合并到 6pac/SlickGrid 分支中,我简要谈谈关于它在本期 post 中,您可以在其中看到动画 gif。但是一直没有时间完成它,我也在等待有人的帮助来完成它。除非我们合并它有
    • 我开始使用的功能是这个 Example from my fork which will eventually be merged. You could use that code and it should work, but you would also require a new SlickGrid Plugin that we created plugins/slick.treeData.js 有一些递归的帮助程序(请记住,使用层次结构对树数据进行排序需要您使用递归,有趣的时间是......如果你喜欢拉你的头发)
  3. 或者最后的选择是使用我的其他库 Slickgrid-Universal which is a wrapper on top of SlickGrid (so it uses the 6pac/SlickGrid fork and is a dependency). This new lib that I created is framework agnostic (it could be used in any framework) and the sample is written in plain TypeScript (or JavaScript is you wish), there's 2 sample for hierarchical dataset Tree Data with parentId references and Tree Data with hierarchical dataset
    • 我最终想在我的库中添加的是支持 SlickGrid built-in 聚合器,但一直没有时间完成它(这实际上与我在顶部写的阻止选项 2 相同)。
  4. 如果您使用的是其他框架,我还创建了另外 2 个库 Angular-Slickgrid and Aurelia-Slickgrid,它们具有与选项 3 相同的功能集。

所以从列表中选择你的选择,这不是一件容易的事情,但这些是当前的选项,显然选项 1 是最难的,因为选项 2-3 基本上意味着我完成了选项 1 的工作已经.

选项 2 可以在这个 gif 动画中看到