2015-11-20 42 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