是否存在使用 jqGrid 按需分组的解决方案?
我想创建一个分组为 true 的 jqGrid,但只有第一个组展开,而其他组在展开该组时保持折叠状态,已折叠,我需要从服务器加载数据。
有人有解决方案吗?
PS:我需要使用分组,为什么用户可以选择其他列来动态分组。
I'm want to create a jqGrid with grouping:true, but only first group expanded and another groups stay collapsed when expand this group, was been collapsed, I need to load the data from the server.
Someone has a solution for that?
PS: I need use grouping, why the user can be select another columns to group on the fly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要实现您的要求,您应该使用
groupCollapse: true
让所有组以折叠形式显示。例如,然后根据 groupingToggle 网格被填满后。例如,您可以在
loadComplete
中使用以下代码:如果您提醒如何构造网格分组行的 id,您可以将代码简化为以下代码,
请参阅 演示。
要动态更改用于分组的列,您可以使用
groupingGroupBy
方法:例如
$("#list").jqGrid('groupingGroupBy', 'ship_via');
。您应该明白,新的groupField
仅在下次填充网格主体后才会使用。因此,如果您想在服务器上定义分组顺序并将其包含在服务器响应中,您应该在beforeProcessing
内部调用groupingGroupBy
方法,而不是在loadComplete< 内部/代码>。
To implement your requirements you should use
groupCollapse: true
to have all groups displayed in collapsed form. For example likeand then expand the first group with respect of groupingToggle after the grid are filled. For example you can use the following code inside of
loadComplete
:If you remind the fact how the ids of the grouping rows of the grid will be constructed you can reduce the code to the following
See the demo.
To change on the fly the column used for grouping you can use
groupingGroupBy
method:For example
$("#list").jqGrid('groupingGroupBy', 'ship_via');
. You should understand that the newgroupField
will be used only after the next filling of the grid body. So if you want to define on the server the grouping order and include it in the server response you should callgroupingGroupBy
method inside ofbeforeProcessing
and not inside ofloadComplete
.设置数据类型:'local'
然后
$("#list").setGridParam({datatype:'json'}).trigger('reloadGrid',[{page:1}]);
set your datatype:'local'
then
$("#list").setGridParam({datatype:'json'}).trigger('reloadGrid',[{page:1}]);