tonytomov / jqGrid

jQuery grid plugin
www.trirand.com
2.84k stars 1.2k forks source link

Summary not formatted on grouping header #1034

Closed fredsal closed 1 year ago

fredsal commented 1 year ago

On footer row and footer group the field appears formatted, but on header group doesn't

image

Demo: https://jsfiddle.net/132xkcLa/

Best regards, Fred

tonytomov commented 1 year ago

I try to fix the problem. Please let me know if the fix work for you.

fredsal commented 1 year ago

With that the demo is not showing anything Master: https://jsfiddle.net/1wqLn8fc/ (https://github.com/tonytomov/jqGrid/commit/d8be5458990ba0e1878d793171756251d15b1547) V5.8.2: https://jsfiddle.net/9knq2u1g/

fredsal commented 1 year ago

How about making it optional, so you avoid breaking changes? Example: summaryFormat: 'currency' Or summaryFormat: true, when true it uses formatter from colModel

there are many custom formatters, and I don't think they can be applied to the group header row

tonytomov commented 1 year ago

In jqGrid setup of your demo change datatype from 'local' to 'json'. It work for me when I do this change.

fredsal commented 1 year ago

I found another way, apparently you can set a callback on groupText, not pretty, but works

Example: https://jsfiddle.net/v0pjmkts/

 groupText:[(gv,n,s)=>
     $.jgrid.template(
        '{0}<span class="right"><b>TOTAL:</b>&nbsp;&nbsp;{2}</span>',
        gv,n,$.fn.fmatter.call(grid[0],'currency',s[1].v),s
     )
],
tonytomov commented 1 year ago

By default summary fields are formated with the formatter when applied. The data on header and footer row can be formated and can be not depending on the parameter - formatHeaderData formatFooterData. The only exception was the grouping text, which is fixed with last commit.

fredsal commented 1 year ago

Ok, my mistake, seems to be working fine, thank you very much

fredsal commented 1 year ago

One question, after changing the values ​​of any cell, is there a function to force the recalculation of the summary of that group?

Example: https://jsfiddle.net/Lbuvyt3z/ image

With reloadGrid it works

grid.trigger('reloadGrid',{page:1});

the only way is reloadGrid, Or is there a method for update only the selected group? I'm trying to avoid groupingRemove and groupingGroupBy again

parallels999 commented 1 year ago

hi @tonytomov,

I use gridConc.getGridParam("groupingView").groups for getting group totals(for custom calculations) With this change, now i only get formated values(breaking change for me), there is a possibility that we can get the value without formatting too, for example

v : 'FORMATED_VALUE',
vv: UNFORMATD_VALUE
tonytomov commented 1 year ago

I have added this requirement, but the property is named uv (un-formatted value) . Maybe it is a good idea to have option what to display - formatted or un-formatted value

parallels999 commented 1 year ago

Maybe it is a good idea to have option what to display - formatted or un-formatted value

that would be great