如何计算列的总和,并显示在FooterRow在jqGrid的在Asp.net [英] How to calculate the Sum of Column and show On FooterRow In Jqgrid in Asp.net

查看:1281
本文介绍了如何计算列的总和,并显示在FooterRow在jqGrid的在Asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

斐伊川家伙!
               我显示的数据中的jqGrid并启用了footerrow:真正的'中的jqGrid现在按照我的需要,我想显示在页脚行特定的列的总和......嘿家伙,我使用的jqGrid对于第一次帮我...

Hii Guys!! I displayed data in jqgrid and enabled ' footerrow: true' in jqgrid Now as per my need i want to show the sum of particular column on footer Row...Plz guys Help me as I am using Jqgrid For first time ...

在此先感谢....

推荐答案

如果你想总结这是在jqGrid的价值观,你可以pferably做到这一点在JavaScript中($ P $在 gridComplete 事件):

If you want to sum the values which are in the jqGrid, you can do that in JavaScript (preferably in gridComplete event):

$('#gridId').jqGrid({
    ...
    footerrow: true,
    gridComplete: function() {
        var $grid = $('#gridId');
        var colSum = $grid.jqGrid('getCol', '<Your column name>', false, 'sum');
        $grid.jqGrid('footerData', 'set', { 'Your column name>: colSum });
    }
});

如果您需要计算在服务器端的总和,那么你必须启用 userDataOnFooter 首选项:

If you need to calculate the sum on the server side, then you must enable userDataOnFooter option first:

$('#gridId').jqGrid({
    ...
    footerrow : true,
    userDataOnFooter : true
});

然后在您的服务器响应的总和。对于JSON的情况下,exmple它应该是这样的:

And then include the sum in your server response. For exmple in case of JSON it should look like this:

{
    total: x,
    page: y,
    records: z,
    rows : [
        ...
    ],
    userdata: { <Your column name>: <sum counted on server side> }
}

您也可以 jqGrid的演示页面上可用来看看活生生的例子(您应选择在新3.5版,然后选择摘要尾行)。

You can also take a look at live example available on jqGrid Demos page (you should choose "New in Version 3.5" and then "Summary Footer Row").

这篇关于如何计算列的总和,并显示在FooterRow在jqGrid的在Asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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