0

The jqGrid's website has following code example about how to use grouping feature, it works very well.

 $(document).ready(function(){ var mydata = [ {id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} , {id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"}, .... ]; $("#list48").jqGrid({ data: mydata, datatype: "local", height: 'auto', rowNum: 30, rowList: [10,20,30], colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"}, {name:'name',index:'name', width:100, editable:true}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true}, {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, {name:'note',index:'note', width:150, sortable:false} ], pager: "#plist48", viewrecords: true, sortname: 'name', grouping:true, groupingView : { groupField : ['name'], groupDataSorted:false, groupColumnShow:[true] }, caption: "Grouping Array Data" }); 

But if I remove:

data: mydata, 

And compose the grid by using addRowData:

$('#list48').addRowData("id", mydata); 

The grouping disappeared, anybody experience similar issue ? Could you please help?

Thanks!

3 Answers 3

1

Try calling sortGrid after addRowData. That worked for me. Syntax for sortGrid is at http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods

var sortByColumnKey = 'StartDate'; $('#grid').jqGrid('sortGrid', sortByColumnKey, true); 
Sign up to request clarification or add additional context in comments.

Comments

0

I too had the same issue. Just triggering 'reloadGrid' solved it for me. $('#grid').trigger('reloadGrid');

Comments

0

Grouping is not taken after adding rows on $('#list48').addRowData("id", mydata);

You should re-group with new data added in grid. Try this after adding rows to grid.

$('#list48').jqGrid('groupingGroupBy', 'name', { groupDataSorted:false, groupColumnShow:[true] }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.