Jquery Datatables 分组插件 - 一种可扩展二级分组的方法?
关于 jquery datatables 行分组插件: http://jquery-datatables- row-grouping.googlecode.com/svn/trunk/index.html ,是否可以进行两级分组并且两个分组都可以展开/折叠?我在网站上找不到任何提到这一点的内容..想知道是否有人尝试过
Concerning the jquery datatables rowgrouping plugin: http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/index.html , is it possible to have the two-level grouping and also have both groupings expandable / collapsible? I couldn't find anything on the site mentioning this.. wondering if any has tried it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也没有看到任何有关插件执行此操作的信息。我认为最有效的解决方案(就运行时而言)是修改 rowGrouping 插件本身,但是每次创建者更新插件时这可能会变得复杂(据我所知,扩展 jQuery 是不可能的)插件)。
不管怎样,我想出了一个解决方案。它并不漂亮,可以进行很多改进,但希望它至少能够激发一些想法。基本上,我创建了自己的 jQuery 插件,它包装了 rowGrouping 插件(您也可以单独使用中间部分 - 请参阅代码中的注释)。它实例化 rowGrouping dataTable,然后遍历行以查找每个主要组内的子组行。然后,它查找每个子组下的行,并为它们分配该组/子组组合唯一的类。最后,它使用此类作为选择器,在单击子组行时切换行。
以下是您将如何使用它:
希望这会有所帮助。干杯。
I didn't see anything either about the plugin doing this. I think the most efficient solution (in terms of runtime) would be to modify the rowGrouping plugin itself, but that might get complicated every time the creator updates the plugin (and to the best of my knowledge, it's not really possible to extend a jQuery plugin).
Anyway, I came up with a solution. It's not pretty and could stand to use a lot of improvement, but hopefully it serves to spark some ideas at the very least. Basically I created my own jQuery plugin that wraps the rowGrouping plugin (you could also just use the middle part by itself - see notes in code). It instantiates a rowGrouping dataTable then traverses the rows looking for subgroup rows within each major group. Then it finds rows under each subgroup and assigns them a class unique to that group/subgroup combination. Finally, it uses this class as a selector to toggle the rows when a subgroup row is clicked.
And here's how you would use it:
Hope this helps. Cheers.
subgroupId 的初始化应该在每次调用之前
the initialization of subgroupId should be before the each call
将这两个布尔值设置为 true:
Set both of these booleans to true: