JQgrid总金额行 [英] JQgrid total amount row

查看:78
本文介绍了JQgrid总金额行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iv在jqgrid中看到了@Oleg的行总和示例,但我尝试应用它,但它无法正常工作,我具有以下网格,我需要为其计算金额值.

iv seen an example by @Oleg for row total sum in jqgrid but i tried to apply it and it wont work i have the following grid i need to calculate the amount value for it.

colNames: ['ID', 'FTE', 'Workload'],
    colModel: [
                { name: 'ID', index: 'ID', width: 200, align: 'left', hidden: true },

                { name: 'FTEValue', index: 'FTEValue', width: 200, align: 'left', formatter: 'number' },
                { name: 'Workload', index: 'Workload', width: 200, align: 'left' },



    caption: "Activity FTE",
    gridview: true,
    rownumbers: true,
    rownumWidth: 40,
    scroll: 0,
    rowNum: 100,
    sortname: 'ID',
    pager: '#pager',
    sortorder: "asc",
    viewrecords: true,
    autowidth: true,
    height: '100%',
    footerrow: true,
    jsonReader: { root: "GridData", page: "CurrentPage", total: "TotalPages", records: "TotalRecords", repeatitems: false, id: "0" }
};



DutyFTEGrid.prototype.SetupGrid = function (selector) {
    jQuery(selector).html('<table id="grid"></table><div id="pager"></div>');
    var grid = jQuery("#grid").jqGrid(this.gridConfiguration);

    jQuery("#grid").jqGrid('navGrid', '#pager',
    { edit: false, add: false, search: false }, {}, {},
    { // Delete parameters
        ajaxDelOptions: { contentType: "application/json" },
        mtype: "DELETE",
        serializeDelData: function () {
            return ""; 
        },
        onclickSubmit: function (params, postdata) {
            params.url = serviceURL + 'DutyFTE(' + encodeURIComponent(postdata) + ')/';
        }
    });

    var grid = $("#grid");
    var sum = grid.jqGrid('getCol', 'FTE', false, 'sum');
    grid.jqGrid('footerData', 'set', { DriverEn: 'Total FTE:', FTEValue: sum });
};

请帮助您,我已经尝试了您的示例,但是由于某些原因它没有起作用.

Oleg your help please, i have tried your example but it didnt work for some reason.

推荐答案

如果我了解您的要求,您想放在页脚 footerData 方法:

If I understand you correct you want to place in the footer getCol and footerData methods:

var grid = $("#list"),
    sum = grid.jqGrid('getCol', 'amount', false, 'sum');

grid.jqGrid('footerData','set', {ID: 'Total:', amount: sum});

getCol可用于计算金额"列中所有数字的总和,对于footerData,您可以在"'ID'"列的底部放置文本总计:",并在'amount'列的底部.

The getCol can be used to calculate the sum of all numbers from the 'amount' column and with respect of footerData you can place at the bottom of the 'ID' column the text "Total:" and at the bottom of 'amount' column.

已更新:可能是因为将代码放置在错误的位置而引起的问题.代码最安全的地方是loadComplete事件处理程序.查看演示.

UPDATED: Probably you have problems because you place the code in the wrong place. The most safe place for the code is loadComplete event handler. Look at the demo.

这篇关于JQgrid总金额行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆