当前位置:   article > 正文

miniui-datagrid 根据条件合并动态行_grid.mergecells(cells); rowindex

grid.mergecells(cells); rowindex


//根据相同的合同编号进行动态合并相同的值

function onLoadSchedule(e) {
        var grid = e.sender;
 var len = grid.data.length;
        var i=0,num=1;
       //定义数组
       var marges=[];
      for(i;i<len;i++){
                if(i==len-1 ){
               var k=i+1-num;
               //动态添加合并的参数,rowIndex开始行数(0开始),columnIndex列数(0开始),rowSpan合并的行数,colSpan合并的列数
              marges.push({rowIndex: k, columnIndex: 1, rowSpan: num, colSpan: 0},
                                    {rowIndex: k, columnIndex: 2, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 3, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 4, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 5, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 6, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 12, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 13, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 14, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 15, rowSpan: num, colSpan: 0},
       {rowIndex: k, columnIndex: 16, rowSpan: num, colSpan: 0});
                  num=1;
   grid.mergeCells(marges);
      continue;
}
//如果两个数的编号相等
if(grid.data[i].Code == grid.data[i+1].Code){
  num++;  //作为计数的参数
}
//编号不相等的时候进行合并
if( grid.data[i].Code != grid.data[i+1].Code){
//取出要合并的行数,i从0开始
var k=i+1-num; 
//动态添加合并的参数
marges.push({rowIndex: k, columnIndex: 1, rowSpan: num, colSpan: 0},
            {rowIndex: k, columnIndex: 2, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 3, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 4, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 5, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 6, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 12, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 13, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 14, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 15, rowSpan: num, colSpan: 0},
 {rowIndex: k, columnIndex: 16, rowSpan: num, colSpan: 0});
 //清空num值
           num=1;
}
 grid.mergeCells(marges);

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/171134
推荐阅读
  

闽ICP备14008679号