2015-11-20 31 views
1

我有一个jqgrid,具有3个级别的分组,如图所示。 我需要为account列上的每个组添加摘要,如图中所示。 jqgridJqgrid:Multi Level Group Summary

ColModel

colModel:[ 
    {name:'typeId',   jsonmap : 'cell.typeId',   width:'100', hidden:true}, 
    {name:'typeName',  jsonmap : 'cell.typeName',   width:'100', hidden:true, summaryType:nameSummary}, 
    {name:'classId',  jsonmap : 'cell.classId',   width:'100', hidden:true}, 
    {name:'className',  jsonmap : 'cell.className',   width:'100', hidden:true, summaryType:nameSummary}, 
    {name:'groupId',  jsonmap : 'cell.groupId',   width:'100', hidden:true}, 
    {name:'groupName',  jsonmap : 'cell.groupName',   width:'150', hidden:true, summaryType:nameSummary}, 
    {name:'accountCode', jsonmap : 'cell.accountCode',  width:'75'}, 
    {name:'accountName', jsonmap : 'cell.accountName',  width:'460'}, 
    {name:'openingBalance', jsonmap : 'cell.openingBalance', width:'110', align:"right", formatter:amountFormatter, summaryType:'sum'}, 
    {name:'debitTotal',  jsonmap : 'cell.debitTotal',  width:'110', align:"right", formatter:amountFormatter, summaryType:'sum'}, 
    {name:'creditTotal', jsonmap : 'cell.creditTotal',  width:'110', align:"right", formatter:amountFormatter, summaryType:'sum'}, 
    {name:'closingBalance', jsonmap : 'cell.closingBalance', width:'110', align:"right", formatter:numberFormatter, summaryType:'sum'}  
], 

分组选项

grouping: true, 
groupingView : { 
    groupField : ['typeId','classId','groupId'], 
    groupText : ['<div style="background: none repeat scroll 0 0 #307ECC; color:white; font-size : 16px;" class="ui-jqgrid-titlebar ui-widget-header"><b> {typeName} </b></div>', 
       '<div style="background-color: #E0ECF8; font-size : 14px;" class="">{className}</div>', 
       '<div style="font-size : 13px;"><b> {groupName} </b></div>'], 
    groupCollapse : false, 
    groupOrder: ['asc','asc','asc'], 
    groupColumnShow: [false,false,false], 
    groupSummary : [true, true, true] 
}, 

我怎样才能做到这一点? 我正在使用jQuery jqGrid v4.5.2

回答

1

在我发布前一段时间the answer。对于两个分组级别,旧的jqGrid 4.5.2不可能设置不同的summaryTplaccountName。我在最新版本的免费jqGrid中实现了该功能,您可以在GitHub上找到该功能。

The demo使用

summaryTpl: [ 
    "<span style='color: red'>Total name:</span>", 
    "<span style='color: DarkRed'>Total date:</span>" 
], 
summaryType: ["count", "count"] 

,并显示像下面的图片的结果:

enter image description here