zoukankan      html  css  js  c++  java
  • 加载完毕后执行计算

    $(function () {
    $("#tab").datagrid({
    // singleSelect: true,
    onLoadSuccess: compute,//加载完毕后执行计算
    600, //宽度
    height: 400, //高度
    singleSelect: true, //选中一行的设置
    rownumbers: true, //行号
    url: "grid1.ashx", //请求路径
    title: "学员信息", //标题
    iconCls: "icon-save", //图标
    collapsible: true, //隐藏按钮
    // fit:true, //自动大小
    collapsible:false,
    //冻结列
    frozenColumns: [[{ field: "chk", "checkbox": true}]],
    //列
    columns: [[
    { field: "JSON_no", title: "编号", 80 },
    { field: "JSON_name", title: "姓名", 100 },
    { field: "JSON_pwd", title: "密码", 100 },
    { field: "JSON_sex", title: "性别", 100 },
    { field: "JSON_age", title: "年龄", 100 },
    { field: "JSON_address", title: "住址", 100 }
    ]],
    //传输参数
    queryParams: { "action": "query" },
    pagination: true,
    toolbar: "#tool"
    // toolbar: [{
    // id: "btnadd",
    // text: "添加",
    // iconCls: "icon-add"
    // },
    // {
    // id: "btnEdit",
    // text: "编辑",
    // iconCls: "icon-edit"
    // },
    // {
    // id: "btncut",
    // text: "删除",
    // iconCls: "icon-no",
    // handler: function () {
    // $("#btnsave").linkbutton("enable");
    // delete_dg();
    // }
    // },
    // ]
    });
    $("#tab").datagrid('getPager').pagination({
    beforePageText: "第",
    afterPageText: "页",
    displayMsg: "当前 {from} - {to}条数据 共{total} 条数据",
    pageSize: 10,
    pageList: [5, 10, 15, 20, 30]

    });
    })

    function compute() {//计算函数
    var rows = $('#tab').datagrid('getRows')//获取当前的数据行
    var ptotal = 0//计算listprice的总和
    , utotal = 0;//统计unitcost的总和
    for (var i = 0; i < rows.length; i++) {
    ptotal += rows[i]['JSON_age'];
    utotal += rows[i]['JSON_pwd'];
    }
    //新增一行显示统计信息
    $('#tab').datagrid('appendRow', { itemid: '<b>统计:</b>', JSON_age: ptotal, JSON_pwd: utotal });
    }

  • 相关阅读:
    java之获取变量的类型
    java中的++和--
    java(三)基础类型之间的转换
    golang数据结构之总结
    golang数据结构之树的三种遍历方式
    golang数据结构之散哈希表(Hash)
    golang数据结构之递归解决迷宫问题
    golang数据结构之利用栈求计算表达式(加减乘除)
    golang数据结构之栈
    golang数据结构之快速排序
  • 原文地址:https://www.cnblogs.com/yangpeng-jingjing/p/5139277.html
Copyright © 2011-2022 走看看