0

I need to group my jqgrid partially.

I have a case if the grouping column has more than one record, I have to group otherwise I need to show it directly.

Example : In the below example groupingId is the group column, need to group the first 2 records but not the third record.

var data = [{
groupingId:001,
invoice:1,
amount:5.00
},{
groupingId:001,
invoice:2,
amount:10.00
},{
groupingId:002,
invoice:3,
amount:8.00
}];


var colNames = ['Invoice','Amount'];

Thanks in advance.

  • Which **version** of jqGrid you use and from which **fork** ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7)? Which `datatype` you use? In general, what you need is 1) to expand all groups which has only one element 2) hide grouping header of such groups. See [the old answer](https://stackoverflow.com/a/13731757/315935) as the starting point. The code in recent version of jqGrid could be a little other. Additionally, the demo expands *all groups*. One can expand only one-item-groups. – Oleg May 29 '18 at 05:33
  • Thanks for your direction Oleg.I am using free jqGrid with datatype as local. – Arunkumar Pushparaj May 29 '18 at 07:27
  • You are welcome! Do you want to display groups, with more as one item in the group, collapsed or expanded? Which grouping option you use? It's especially important to know whether you use more as one level of grouping (it will be mostly difficult) and the options `groupColumnShow, groupSummaryPos, groupSummary`. What I mean: one can have very different look of grouping data in jqGrid. It's important to know more details about how you use it. – Oleg May 29 '18 at 07:37
  • No, I want to group by only one field with expanded. It works with the help of your demo from here http://ok-soft-gmbh.com/jqGrid/HideSomeGroupingHeaders1.htm. – Arunkumar Pushparaj May 29 '18 at 08:44
  • Is it possible to sort after removing those single value group? Because the single value group got merged into the multivalue group. – Arunkumar Pushparaj May 29 '18 at 08:51
  • Even if one hides grouping header the value of grouping will be used by sorting. For example, if you group by country and sort by city then the sorting be done by **two** fields: country,city. Thus one can't so easy sort by country ignoring country. If you do need to implement that then you will have to implement *custom sorting* by defining `sortfunc` callback (see [here](https://github.com/free-jqgrid/jqGrid/blob/v4.15.4/ts/free-jqgrid.d.ts#L779) and [here](https://stackoverflow.com/a/40201448/315935)) – Oleg May 29 '18 at 10:01

0 Answers0