zoukankan      html  css  js  c++  java
  • easyui datagrid合并相同数据的单元格。

        /**
         * 根据作用域填充单元格
         */
        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
                        });
    
                        tTable.datagrid("mergeCells", { //根据ColArray[j]进行合并
                            index: i - tmpA,
                            field: "fiveMinutesAvg",
                            rowspan: tmpA,
                            colspan: null
                        });
    
                        tmpA = 1;
                    }
                    PerTxt = CurTxt;
                }
            }
        }

    使用示例:

    $('#datagrid_1').datagrid({
           
            onLoadSuccess: function () {
                mergeCellsByField('datagrid_1', "dataTime");
            }
        })
  • 相关阅读:
    zoj 1239 Hanoi Tower Troubles Again!
    zoj 1221 Risk
    uva 10192 Vacation
    uva 10066 The Twin Towers
    uva 531 Compromise
    uva 103 Stacking Boxes
    稳定婚姻模型
    Ants UVA
    Golden Tiger Claw UVA
    关于upper、lower bound 的探讨
  • 原文地址:https://www.cnblogs.com/yeminglong/p/11468412.html
Copyright © 2011-2022 走看看