【问题标题】:jqGrid Summary HeaderjqGrid 摘要标题
【发布时间】:2014-06-22 20:28:10
【问题描述】:

我一定是做错了什么。当我使用 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”时,我没有得到预期的结果。 结果右移一列,总数不正确。

以下是所见结果的摘要:

使用“页脚”,我得到了这个(部分)结果

项目代码 Req'd 2014 资金 认购 资金 投票 补充资金 投票 总资金 投票 通讯-0 研究-0 程序-0 项目 1 $1,000 $100 $10 $110 项目 2 $2,000 $200 $20 $220 项目 3 $3,000 $300 $30 $330 项目 4 $4,000 $400 $40 $440 项目 5 $5,000 $500 $50 $550 $15,000 $1,500 $150 $1,650-Program-0 的摘要页脚 程序一 项目 6 $6,000 $600 $60 $660 项目 7 $7,000 $700 $70 $770 项目 8 $8,000 $800 $80 $880 项目 9 $9,000 $900 $90 $990 项目-10 $10,000 $1,000 $100 $1,100 $40,000 $4,000 $400 $4,400-Program-1 的摘要页脚 $55,000 $5,500 $550 $6,050-Research-0 的摘要页脚

使用“标题”,我得到了这个(部分)结果

项目代码 Req'd 2014 资金 认购 资金 投票 补充资金 投票 总资金 投票 Comm-0 $210,000 $21,000 $2,100 $23,100 Research-0 $55,000 $5,500 $550 $6,050-Research-0 总结 Program-0 $55,000 $5,500 $550 $6,050-Program-0 总结 项目 1 $1,000 $100 $10 $110 项目 2 $2,000 $200 $20 $220 项目 3 $3,000 $300 $30 $330 项目 4 $4,000 $400 $40 $440 项目 5 $5,000 $500 $50 $550 计划 1 55,000 美元 5,500 美元 550 美元 6,050 美元 - 计划 1 总结 项目 6 $6,000 $600 $60 $660 项目 7 $7,000 $700 $70 $770 项目 8 $8,000 $800 $80 $880 项目 9 $9,000 $900 $90 $990 项目-10 $10,000 $1,000 $100 $1,000

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

【问题讨论】:

    标签: jquery jquery-plugins jqgrid


    【解决方案1】:

    我遇到了完全相同的问题。仅当按 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') 内)。

    【讨论】:

    • 这确实更正了总数。我不知道你是怎么想出来的。但是,列移位(向右)仍然发生。
    • 我相信列移位与 groupColumnShow = false 有关。不知道如何解决这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多