开发者

jqGrid and Dynamic Grouping

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');      


Disregard.

In my grid's initial initialization, setting full options for the groupingView parameter, while setting grouping: false did the trick.

...
    grouping: grouping,
       groupingView : {
          groupField : [groupColParam],
          groupColumnShow : [true],
          groupText : ['<b>{0}</b>'],
          groupCollapse : true,
          groupOrder: ['asc'],
          groupSummary : [false]
       },
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜