Calculate average of two sums from two column and show it in next column in JQGrid

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 10:29:01

Yes, it should be fairly straightforward to do this.

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

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

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

The custom formatter function:

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

   return rowObject[ColumnOneIndex] * rowObject[ColumnTwoIndex]; 
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!