jqGrid摘要标题

时间:2014-05-06 09:40:14

标签: jquery jquery-plugins jqgrid

我一定是做错了。当我使用groupSummary true和groupSummaryPos页脚进行分组时,一切看起来都是正确的。

jQuery(function () {
    jQuery("#list").jqGrid({
        url: "/ballot/ballot/format/xml",
        datatype: "xml",
        mtype: "POST",
        colNames: [],
        colModel: [
            { label: 'Committee', name: 'comm', align: 'left' },
{ label: 'Research Area', name: 'resa', align: 'left' },
{ label: 'Program', name: 'prog', align: 'left' },
{ label: 'Project Code', name: 'proj', align: 'left' },
{ label: 'Req\'d 2014 Funding', name: 'freq', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: 'Subscription Funds Voted', name: 'vsub', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: 'Supplemental Funds Voted', name: 'vsup', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: 'Total Funds Voted', name: 'total', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: '% Funded', name: 'note', align: 'center', sortable: '', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 1, prefix: "", suffix:"%", defaultValue: "0.00"} },
{ label: 'In-kind Support Voted', name: 'iks', align: 'left' },
{ label: 'Level Of Commitment', name: 'loc', align: 'left' },
{ label: 'Add\'l 2014 Funds Required', name: 'freqadd', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: 'Out Years Funding Req\'d', name: 'freqout', align: 'right', formatter: 'currency', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$", suffix:"", defaultValue: "0.00"}, summaryType: 'sum' },
{ label: 'Companies Voting', name: 'comps', sortable: '' }
        ],
        pager: "#pager",
        rowNum: 20,
        height: 300,
        viewrecords: true,
        gridview: true,
        autoencode: true,
        caption: "Ballot",
        postData: {filterset: jQuery("#filterset").val()},
        autowidth: true,
        shrinkToFit: false,
        grouping: true,
        groupingView : {
            groupField : ['comm','resa','prog'],
            groupOrder : ['asc','asc','asc'],
            groupSummary: [true, true, true],
            groupColumnShow: [false, false, false],
            groupSummaryPos: ['footer', 'footer', 'footer']
        }
    }); 
});

这正是我所期望的。 但是,当我将上面的groupSummaryPos更改为'header'时,我没有得到预期的结果。 结果向右移动一列,总计不正确。

以下是所见结果的摘要:

使用'footer',我得到这个(部分)结果

Project Code    Req'd 2014 Funding    Subscription Funds Voted    Supplemental Funds Voted    Total Funds Voted
Comm-0
Research-0
Program-0
Project-1    $1,000    $100    $10        $110    
Project-2    $2,000    $200    $20        $220    
Project-3    $3,000    $300    $30        $330    
Project-4    $4,000    $400    $40        $440    
Project-5    $5,000    $500    $50        $550    
            $15,000    $1,500    $150    $1,650-Summary footer for Program-0
Program-1
Project-6    $6,000    $600    $60        $660
Project-7    $7,000    $700    $70        $770
Project-8    $8,000    $800    $80        $880
Project-9    $9,000    $900    $90        $990
Project-10    $10,000    $1,000    $100    $1,100
            $40,000    $4,000    $400    $4,400-Summary footer for Program-1    
            $55,000    $5,500    $550    $6,050-Summary footer for Research-0

使用'header',我得到这个(部分)结果

Project Code    Req'd 2014 Funding    Subscription Funds Voted    Supplemental Funds Voted    Total Funds Voted
Comm-0                 $210,000    $21,000  $2,100  $23,100
Research-0             $55,000    $5,500    $550    $6,050-Summary for Research-0
Program-0              $55,000    $5,500    $550    $6,050-Summary for Program-0
Project-1    $1,000    $100       $10       $110
Project-2    $2,000    $200       $20       $220
Project-3    $3,000    $300       $30       $330
Project-4    $4,000    $400       $40       $440
Project-5    $5,000    $500       $50       $550
Program-1              $55,000    $5,500    $550    $6,050-Summary for Program-1
Project-6    $6,000    $600       $60       $660
Project-7    $7,000    $700       $70       $770
Project-8    $8,000    $800       $80       $880
Project-9    $9,000    $900       $90       $990
Project-10   $10,000   $1,000    $100       $1,000

关于为什么标题摘要似乎不起作用的任何想法?

1 个答案:

答案 0 :(得分:0)

我遇到了完全相同的问题。它仅在按3(或更多)字段分组并将groupSummaryPos设置为标题时发生。 我正在使用Jqgrid V. 4.6.0。

经过大量研究后,我能够通过更改jqGrid js文件中的一行来解决问题。 在迭代grp.groups的函数中,替换了行:

str += buildSummaryTd(i, n.idx - 1, grp.groups, 1);

使用:

str += buildSummaryTd(i, 0, grp.groups, 1);

(此行在条件if (grp.groupSummaryPos[n.idx] === 'header')内)。