计算两列中两个和的平均值,并在JQGrid的下一列中显示它 [英] Calculate average of two sums from two column and show it in next column in JQGrid

查看:401
本文介绍了计算两列中两个和的平均值,并在JQGrid的下一列中显示它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在分组级别使用Jqgrid和summery行!现在我想知道一件事,是否有可能显示从两个不同列的总结计算出的平均值?因为Sum是通过JQGrid功能计算的。这就是我不确定是否可能的原因!在这里我附上了我的屏幕截图请参考。

I'm using Jqgrid with summery row at grouping level! Now I want to know one thing, that Is it possible to show average calculated from two summery of different column ? Because Sum is calculating by JQGrid functionality. That's why I'm not sure is it possible or not! Here I've attached my screen shot Please refer that.

在此期间,预测和收入的总和正确显示。我需要在Accuracy列的总和位置显示incomeum / forecastum * 100的平均值。
是否可以通过任何JavaScript编码或JQGrid功能实现它?

In this the sum of forecast and revenue are is showing correctly. I Need to show the average of revenuesum/forecastsum*100 in the sum row place in Accuracy column. Is it possible to achieve it through any JavaScript coding or JQGrid functionality also?

推荐答案

是的,这样做应该相当简单。

Yes, it should be fairly straightforward to do this.

首先在colModel中的正确位置添加名称,然后在jqGrid设置中,您可以通过以下方式注入空白列:

Start by adding in the name in the right location int he colModel, then in your jqGrid setup you can inject a blank column via:

        beforeProcessing: function (data, status, xhr) {
            //add a "blank" column that will be built
            for (var x = 0, length = data.rows.length; x < length; x++) {
                data.rows[x].cell.splice(ColumnIndexValueToAddBlank,0, "");
            }//for
        }, //beforeProcessing

然后在该列中在jqGrid中设置(在colModel设置中的正确位置)

then in that column setup in the jqGrid (in the right location in the colModel setup)

        { name: "CalculatedColumn", .... , formatter: CalculatedFormatFunction

自定义格式化函数:

  function CalculatedFormatFunction(cellval, opts, rowObject, action) {

   return rowObject[ColumnOneIndex] * rowObject[ColumnTwoIndex]; 
  }

这篇关于计算两列中两个和的平均值,并在JQGrid的下一列中显示它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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