2

I am using jqGrid-4.4.1 with grouping columns.

I am able to get grouping but I do need something similar like this:

Old Version Of Grid

Sample Code for jqGrid:

$("#gridData").jqGrid({
                    colModel: colData, // col model array
                    colNames: colNamesArray, // column names array
                    data: rows, // data
                    datatype: "local", 
                    height: 'auto',
                    width: '100%',
                    viewrecords: false,
                    sortorder: "asc",
                    gridview: true,
                    grouping:true, 
                    groupingView: { 
                        groupField: ['Group'],
                        groupColumnShow: [false]
   
                    }
                   
                }

);

Currently, I have something like this: but I need comma separated values in the Grouping Row for each Column.

Web View

I have values as comma separated String. But I am not getting how it can be mapped with column

Is it possible ? Any pointers would be really great.

Community
  • 1
  • 1
Hardik Mishra
  • 14,779
  • 9
  • 61
  • 96
  • http://stackoverflow.com/questions/10803081/jqgrid-grouping-grouptext-formatting-and-modification – Mark Jan 03 '13 at 13:53
  • @Mark: Thanks for the link. I am aware with that. In my case I need summary row for each column. – Hardik Mishra Jan 04 '13 at 04:55
  • Very interesting, I looked around, but currently the only way I see to accomplish what you are wanting would be to modify the Grouping row similar to the link I posted, but then build up columns again in that row for each Day column you are showing and add them into that row. It would be a bit hackish but should work...or someone else will come in with a better answer. – Mark Jan 04 '13 at 12:38
  • @Mark: Again thanks for looking around. One of the way I found is to have subGrid with hidden column headers. But I am struggling in hiding subGrid columns. Ref Link : http://stackoverflow.com/questions/14155735/jqgrid-remove-column-headers-from-subgrid – Hardik Mishra Jan 04 '13 at 12:56
  • I looked at that question and investigated it as well. With the right jQuery syntax you should be able to just use a `.hide()` call to hide the subgrid. With that method will your summary row be visible though without expanding the group? – Mark Jan 04 '13 at 13:20
  • @Mark: In that question, I am not using grouping. Instead of that I am creating main grid for each group and sub grid for items under the group.So, It shall be visible. – Hardik Mishra Jan 04 '13 at 13:29
  • Without having to expand each row manually? Or do you display all subgrids? – Mark Jan 04 '13 at 13:33
  • Well.. I have to expand required rows manually. As default behavior is collapse. – Hardik Mishra Jan 04 '13 at 13:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22184/discussion-between-mark-and-hardik-mishra) – Mark Jan 04 '13 at 13:44

1 Answers1

2

I would recommend you to use groupSummary: [true] option of groupingView to create additional summary row. One need to define summaryType property for all columns in the colModel where the summary row should be not empty and optionally summaryTpl. In the answer I shown how to create custom value in the summary row.

You can create custom grouping row like in the answer alternatively. The main reason why I recommend you to use groupSummary option of groupingView instead of creating custom is the implementation of grouping row in jqGrid. jqGrid use colspan attribute to make the grouping row spanned over all columns. What you need is summary information for every column. So the inner structure of grouping summary is better for your requirements. The only disadvantage is that the summary information will be not shown for collapsed groups.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks a ton for the reply. I have gone through your SO profile and I am really motivated from your nature and attitude towards replying questions. God bless you Sir.. – Hardik Mishra Jan 04 '13 at 16:51
  • While searching for alternate solution for this requirement, I came across to use subGrid with out Column headers. But, I will also check this one. – Hardik Mishra Jan 04 '13 at 16:53
  • @HardikMishra: Both solution will have close look. You should decide better based on other requirements of your project what way is better for you and which one is more close to the nature of the information displayed in the grid. – Oleg Jan 04 '13 at 17:02
  • @Oleg There is probably no easy way to move that groupSummary row is there? I took from the example a key requirement for the summary information to be at the top of the grouping row. I was only making assumptions however. – Mark Jan 04 '13 at 17:35
  • @HardikMishra: I think it will be not difficult to move summary row. Look at [the answer](http://stackoverflow.com/a/5402655/315935). In the same way you can move grouping summary row too. – Oleg Jan 04 '13 at 17:39