js 版的jqgrid +汇总

来源:互联网 发布:仿真物理实验室软件 编辑:程序博客网 时间:2024/05/16 19:41

html: <div>
      <table id="igrid"></table>
    </div>



js:    // jQuery("#igrid").jqGrid({
    //   url: '/ycrm/Tenantsproducts/selModel',
    //   datatype: "json",
    //   colModel: [
    //     {name:'org_id', label:'租户ID', index:'org_id'},
    //     {name:'product_id', label:'产品ID', index:'product_id', searchoptions:{sopt:['cn']}},
    //     {name:'buy_quantity', label:'购买量', index:'buy_quantity', searchoptions:{sopt:['cn']}},
    //     {name:'use_quantity', label:'使用量', index:'use_quantity', searchoptions:{sopt:['cn']}}
    //   ],
    //   // multiselect: true,
    //   width:580,
    //   height:150,   //设置高度
    //   loadonce:true,
    //   gridview:true, //加速显示
    //   rownumbers:true,
    //   scroll:1 // 不分页
    // }); 
    // jQuery("#igrid").jqGrid('filterToolbar',{searchOperators : true}); 



php:public function selModel(){
        $Tenantsproduct = M('Tenantsproduct');
        $Tenantsproduct->field('org_id,product_id,buy_quantity,use_quantity');
        // $Tenantsproduct->where('org_id='.$this->org_id);
        $result = $Tenantsproduct->select();
        echo json_encode($result);
      }


汇总

var sum = $("#igrid").getCol('money',false,'sum');
sum = sum.toFixed(2);
0 0