jqGrid和动态分组 [英] jqGrid and Dynamic Grouping

查看:924
本文介绍了jqGrid和动态分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为jqGrid进行一些动态分组,根据以下示例发布: http://www.trirand.com/blog/jqgrid/jqgrid.html (请参阅树导航栏的最后一节:分组:动态更改分组。



我可以使我的网格动态地改变网格最初具有分组列的分组IFF,但是这不是所需的行为。最初,网格需要被取消分组,并允许用户对它们进行分组。 / p>

代码如下:

  function onGroupByChanged(){
var vl = $('#lstGroupBy')。val();
if(vl){
if(vl ==clear){
$(#refData)。 jqGrid('groupingRemove',true);
} else {
$(#refData)jqGrid('groupingGroupBy',vl);
$(#refData)jqGrid ('setGridParam',{grouping:true});
$('#refData')。trig ger('reloadGrid');
}
}
}

当我将groupingGroupBy设置为列名(包含在vl)中时,我在FireBug中收到此错误:无法在jQuery中将null转换为对象最小1.4.2



我甚至将我的电话顺序交换为groupingGroupBy并将分组设置为true。



任何人都有想法?我已经停了,已经花了大约两个小时了。



谢谢,
Randall

解决方案

  var GroupOption = new Object(); 
var groupField = [];

groupField.push(vl);

GroupOption.groupField = groupField;
GroupOption.groupColumnShow = true;
GroupOption.groupCollapse = false;
GroupOption.groupText = ['< strong> {0} - {1}项目< / strong>']

$(#refData)。setGridParam({groupingView:GroupOption});
$(#refData)。setGridParam({grouping:true});
$(#refData)。trigger('reloadGrid');


I'm working on some dynamic grouping of my jqGrid, per the example posted at: http://www.trirand.com/blog/jqgrid/jqgrid.html (see the last section in the tree nav: 'Grouping: Dynamically Change Grouping'.

I can make my grid dynamically change the grouping IFF the grid initially has a grouping column. However, this is not the desired behaviour. Initially the grid needs to be ungrouped and allow the user to group items if they choose.

Code follows:

function onGroupByChanged(){
    var vl = $('#lstGroupBy').val();
    if(vl) {
        if(vl == "clear") {
            $("#refData").jqGrid('groupingRemove',true);
        } else {
            $("#refData").jqGrid('groupingGroupBy', vl);
            $("#refData").jqGrid('setGridParam', { grouping:true });
            $('#refData').trigger('reloadGrid');
        }
    }   
}

When I set the groupingGroupBy to the column name (contained in 'vl'), I receive this error in FireBug: can't convert null to object in jQuery min 1.4.2

I have even swapped the order of my calls to groupingGroupBy and setting grouping to true.

Anyone have an idea? I'm stuck and have spent about two hours on this already.

Thanks, Randall

解决方案

var GroupOption = new Object();
var groupField = [];

groupField.push(vl);

GroupOption.groupField = groupField;
GroupOption.groupColumnShow = true;
GroupOption.groupCollapse = false;
GroupOption.groupText = ['<strong> {0} - {1} Item(s)</strong>']

$("#refData").setGridParam({groupingView : GroupOption});
$("#refData").setGridParam({grouping : true});
$("#refData").trigger('reloadGrid');      

这篇关于jqGrid和动态分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆