Grid标签计算结果集中的合计行

方法一:

var detailT= grid.gettable("11");

    var r=detailT.rows.length;

    detailT.rows[r-1].cells[3].innerHTML=0;

    var colSum=gridreport_getsum(grid, "saleqty");

   

    detailT.rows[r-1].cells[3].innerHTML="<div style='width:100%;text-align:right'>"+parseFloat(colSum)+"</div>";

 

方法二:

var detailT= grid.gettable("11"); 

       var r=detailT.rows.length;

       //alert(r);

       //var c=detailT.rows[0].cells.length-2;

       //alert(c);

       //计算列合计

       //for(var i=5;i<c;i++){//i是列

              var colSum=0;

              for(var j=0;j<r-1;j++){ //j是行

                     var add;

                     if(detailT.rows[j].cells[3].childNodes[0].type=="text"){ 

                         add=parseFloat(detailT.rows[j].cells[3].childNodes[0].value);

                         if(isNaN(add)){

                                   add=0;

                            }

                         colSum+=add;

                  }

           }

           //列合计赋值

           detailT.rows[r-1].cells[3].innerHTML="<div style='width:100%;text-align:right'>"+colSum+"</div>";

           */

       //}

 

posted @ 2015-03-25 13:59  HalfWater  阅读(205)  评论(0编辑  收藏  举报