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

前端 未结 1 1768
暖寄归人
暖寄归人 2021-01-26 00:40

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

相关标签:
1条回答
  • 2021-01-26 00:49

    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]; 
      }
    
    0 讨论(0)
提交回复
热议问题