【问题标题】:Jqgrid : Multi Level Group SummaryJqgrid:多级组摘要
【发布时间】:2015-11-20 07:40:42
【问题描述】:

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

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

【问题讨论】:

    标签: jquery jqgrid


    【解决方案1】:

    在我发布the answer 之前的一段时间。旧的 jqGrid 4.5.2 无法为两个分组级别在 accountName 中设置 不同 summaryTpl。我在最新版本的 free jqGrid 中实现了该功能,您可以在 GitHub 上找到它。

    The demo 使用

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

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

    【讨论】:

      猜你喜欢
      • 2011-01-21
      • 2014-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多