Jqgrid:多级别组摘要

兴趣

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

彩色模型

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

奥列格

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

演示使用

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

并显示如下图所示的结果:

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章