0

Is there other way to have summary at grouping header other than using groupSummaryPos:['header'] ? I am using jqGrid v4.6.0 and unfortunately I cannot upgrade to higher version.

I have a table that I implemented using jqGrid in my project. The gridOptions are very similar with the one mentioned in my previous question here As you can see from the plunkr, the demo works fine and I can show summary on header. However, when I moved the code to my project, the summary always shows on footer. The only difference between my project and the plunkr code is in my project, I am using a reusable component that will initialize jqGrid. I have debugged the code to see if the groupSummaryPos = ['header'] being overridden somewhere in my project by that reusable component, but it gives me no luck.

So, I have decided to go for a workaround. I tried to a 'hack-move' by moving the summary footer DOM element to the grouping header, after the GRID_COMPLETE event, using

var footerContent = jQuery('.jqfooter').children;
jQuery('.jqgroup')[0].children[0].removeAttribute('colspan');
jQuery('.jqgroup')[0].appendChild(footerContent[0]); // till all columns

However, this doesn't work because the appendChild will move each column in random order (I'm not sure why).. In summary, I have tried to use the proper way, which is specifying groupSummaryPos: ['header'] in my colOptions, and also a 'really bad' hack way, but it's not working too.

Is there a possible way to move summary footer to group header without using groupSummaryPos?

Community
  • 1
  • 1
blenzcoffee
  • 851
  • 1
  • 11
  • 35

2 Answers2

1

I think that you should locale which part of your code change groupSummaryPos option. The 'hack-move' solution seems me the wrong way.

You can try to reset groupSummaryPos to 'header' inside of onInitGrid callback as the first attempt. You should verify additionally that gridview: true is set too and nobody modify it.

The groupSummaryPos option will be used inside of groupingRender method whith will be called inside of addJSONData. So you can use beforeProcessing callback (if you loads the data from the server) or beforeRequest. So, if the resetting of groupSummaryPos to 'header' inside of onInitGrid will not work you can do this inside of beforeRequest or inside of beforeProcessing.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • hi Oleg, thanks again for your reply! First I checked my `groupSummaryPos` value inside the onInitGrid and the value is correct, it's still `header`. I also added `gridview: true` and ensure nobody modify it. the way I used onInitGrid is as described by your old answer here http://stackoverflow.com/questions/28778434/jqgrid-event-on-grid-initialization . However the summary is still shown in the footer. My data is from local tho (static variable). Is there any other ways to do it? Thanks again beforehand! – blenzcoffee Apr 01 '15 at 14:13
  • I found the reason why. In my project, I downloaded the dependency using Bower for jqGrid 4.6.0 and use the minified version. Weirdly, the minified version included in jqGrid 4.6.0 is version 4.5.2 (is this a defect?). That's why the summaryPos doesn't work since I believe groupSummaryPos header is not supported in 4.5.2.. Thanks Oleg for ur answer!! – blenzcoffee Apr 01 '15 at 14:39
  • and I believe you pointed this out to Tony Tomov too https://github.com/tonytomov/jqGrid/commit/7216e3866b9c49ebee93d6e09dc5a72eb0460d89 – blenzcoffee Apr 01 '15 at 14:49
  • @blenzcoffee: You are welcome! Now everything is clear. – Oleg Apr 01 '15 at 15:04
0

I found the reason why. In my project, I downloaded the dependency using Bower for jqGrid 4.6.0 and use the minified version. Weirdly, the minified version included in jqGrid 4.6.0 is version 4.5.2 (is this a defect?).This is mentioned in the comments section here

https://github.com/tonytomov/jqGrid/commit/7216e3866b9c49ebee93d6e09dc5a72eb0460d89

That's why the summaryPos doesn't work since I believe groupSummaryPos header is not supported in 4.5.2.. The plunkr version works because it's using the right minified version. Thanks Oleg for ur answer!!

blenzcoffee
  • 851
  • 1
  • 11
  • 35