zoukankan      html  css  js  c++  java
  • easyui datagrid行合并

    easyui datagrid行合并

    合并方法

    /**
    * EasyUI DataGrid根据字段动态合并单元格
    * 参数 tableID 要合并table的id
    * 参数 colList 要合并的列,用逗号分隔(例如:"name,department,office");
    */
    function mergeCellsByField(tableID, colList) {
        var ColArray = colList.split(",");
        var tTable = $("#" + tableID);
        var TableRowCnts = tTable.datagrid("getRows").length;
        var tmpA;
        var tmpB;
        var PerTxt = "";
        var CurTxt = "";
        var alertStr = "";
        for (j = ColArray.length - 1; j >= 0; j--) {
            PerTxt = "";
            tmpA = 1;
            tmpB = 0;
    
            for (i = 0; i <= TableRowCnts; i++) {
                if (i == TableRowCnts) {
                    CurTxt = "";
                }
                else {
                    CurTxt = tTable.datagrid("getRows")[i][ColArray[j]];
                }
                if (PerTxt == CurTxt) {
                    tmpA += 1;
                }
                else {
                    tmpB += tmpA;
                    tTable.datagrid("mergeCells", {
                        index: i - tmpA,
                        field: ColArray[j],  //合并字段
                        rowspan: tmpA,
                        colspan: null
                    });
                    tmpA = 1;
                }
                PerTxt = CurTxt;
            }
        }
    }

    调用方法

     //呈现列表数据
            $('#List').datagrid({ pagination: true,
                onLoadSuccess: function (data) {
                    if (data.rows.length > 0){
              //调用函数合并单元格,2000是延迟加载时间
              setTimeout("mergeCellsByField(/"tbList/", /"No/")",2000);
                    }
                }
            });
  • 相关阅读:
    L1-061 新胖子公式 (10 分)
    L1-060 心理阴影面积 (5 分)
    L1-059 敲笨钟 (20 分)
    Linux高性能服务器编程—进程池和线程池
    epoll系列系统调用
    18.5.2 多线程并发服务器端的实现
    10.4 基于多任务的并发服务器
    侯捷C++(complex类)
    Qt 事件机制
    C++篇49问49答
  • 原文地址:https://www.cnblogs.com/baconLiu/p/6746448.html
Copyright © 2011-2022 走看看