zoukankan      html  css  js  c++  java
  • jgrid相关功能用法记录

    1.获取行号
    var ids = $gridList.jqGrid('getGridParam', 'selarrrow'); //多选,返回选中行号组字符 
    var ids2 = $gridList.jqGrid('getGridParam', 'selrow'); //返回选中行号 

    2.获取行数据
    var ids = $gridList.jqGrid('getGridParam', 'selarrrow');
    for (var i = 0; i < ids.length; i++) {
            var ret = $gridList.jqGrid('getRowData', ids[i]);
            alert(ret.ID);
    }

    3.单元格保存后改变单元格值:
    afterSaveCell: function (rowid, cellname, value, iRow, iCol) {

                    if (newDirtyJson[rowid]) {
                        newDirtyJson[rowid].push(cellname);
                    } else {
                        var newDirtyArray = [];
                        newDirtyArray.push(cellname);
                        newDirtyJson[rowid] = newDirtyArray;
                    }
                    jQuery("#ConsGridDiv").jqGrid().setCell(rowid, 'SynStatus', 0);
                    $("td[aria-describedby=ConsGridDiv_SynStatus]", this.rows[iRow]).addClass("dirty-cell");
                }

    4.加底部统计栏:

    (1)设置属性:
    footerrow: true
    userDataOnFooter: true2)gridComplete
    gridComplete: function (){           
              jQuery("#BurntJqGrid-datagrid").footerData("set", {
                    "WeightAfter": "<span style='color:red;float:right;'>合计</span>"
                });
                //底部合计行计算
                var rowNum = burntJqGrid.getAllRecords().length;
                if (rowNum > 0) {
                    $(".ui-jqgrid-sdiv").show();
                    var Percents = parseFloat($("#BurntJqGrid-datagrid").getCol("Percents", false, "sum") * 100 / rowNum).toFixed(1)+"%";
                    jQuery("#BurntJqGrid-datagrid").footerData("set", { "Percents": "<span style='color:red;float:left'>" + Percents + "</span>" }); //将合计值显示出来
                } else {
                    $(".ui-jqgrid-sdiv").hide();
                }
    
    } 

    效果图:

    5.三级表头合并

    需要插件配合:http://files.cnblogs.com/files/starksoft/jquery.jqGrid.groupHeader-0.2.1.js

    //二级表头合并
        jQuery("#ActiveJqGrid-datagrid").jqGrid('setGroupHeaders', {
            useColSpanStyle: true,
            groupHeaders: [
                            { startColumnName: 'D7_1', numberOfColumns: 2, titleText: '7d' },
                            { startColumnName: 'D28_1', numberOfColumns: 2, titleText: '28d' },
                            { startColumnName: 'S7_1', numberOfColumns: 2, titleText: '7d' },
                            { startColumnName: 'S28_1', numberOfColumns: 2, titleText: '28d' }
                ]
        });
        //三级表头合并
        jQuery("#ActiveJqGrid-datagrid").jqGrid("setComplexGroupHeaders", {
            complexGroupHeaders: [
                                  { startColumnName: 'D7_1', numberOfColumns: 4, titleText: '<em>对比胶砂</em>' },
                                  { startColumnName: 'S7_1', numberOfColumns: 4, titleText: '试样胶砂' }
                 ]
        });

     效果图:

  • 相关阅读:
    类的静态成员
    QT上的Mysql编程
    将博客搬至CSDN
    ARM开发板系统移植-----rootfs的制作
    ARM开发板系统移植-----kernel的编译
    ARM开发板系统移植-----u-boot的编译
    Linux 消息队列编程
    Linux 共享内存编程
    Linux 信号量同步编程
    Linux 信号量互斥编程
  • 原文地址:https://www.cnblogs.com/starksoft/p/6396220.html
Copyright © 2011-2022 走看看