摘自:http://www.cnblogs.com/kunpengit/archive/2012/11/13/2768239.html
/**
* grid gridPanel 需要合并的表格
* rowOrCol 合并行还是列 需要合并的列(dateIndex)
*borderStyle 样式
**/
function gridSpan(grid, rowOrCol,colName, borderStyle) {
var array1 = new Array();
var count1 = 0;
var count2 = 0;
var index1 = 0;
var index2 = 0;
var aRow = undefined;
var preValue = undefined;
var firstSameCell = 0;
var allRecs = grid.getStore().getRange();
if (rowOrCol == "row") {
count1 = grid.getColumnModel().getColumnCount();
count2 = grid.getStore().getCount();
} else {
count1 = grid.getStore().getCount();
count2 = grid.getColumnModel().getColumnCount();
}
count1 = 2; // 对第二列合并
for (i = 1; i < count1; i++) {
preValue = undefined;
firstSameCell = 0;
array1[i] = new Array();
for (j = 0; j < count2; j++) {
if (rowOrCol == "row") {
index1 = j;
index2 = i;
} else {
index1 = i;
index2 = j;
}
if (allRecs[index1].get(colName) == preValue) {
allRecs[index1].set(colName, " ");
array1[i].push(j);
//alert(i + "\r\n"+j);
if (j == count2 - 1) {
var index = firstSameCell + Math.round((j + 1 - firstSameCell) / 2 - 1);
if (rowOrCol == "row") {
allRecs[index].set(colName, preValue);
} else {
allRecs[index1].set(grid.getColumnModel().getColumnId(index), preValue);
}
}
} else {
if (j != 0) {
var index = firstSameCell + Math.round((j + 1 - firstSameCell) / 2 - 1);
if (rowOrCol == "row") {
allRecs[index].set(colName, preValue);
} else {
allRecs[index1].set(grid.getColumnModel().getColumnId(index), preValue);
}
}
firstSameCell = j;
preValue = allRecs[index1].get(colName);
allRecs[index1].set(colName, " ");
if (j == count2 - 1) {
allRecs[index1].set(colName, preValue);
}
}
}
}
grid.getStore().commitChanges();//添加所有分隔线
for (i = 0; i < grid.getStore().getCount(); i++) {
for (j = 0; j < grid.getColumnModel().getColumnCount(); j++) {
aRow = grid.getView().getCell(i, j);
aRow.style.borderTop = borderStyle;
aRow.style.borderLeft = borderStyle;
}
}//去除合并的单元格的分隔线
for (i = 1; i < array1.length; i++) {
for (j = 0; j < array1[i].length; j++) { if (rowOrCol == "row") {
aRow = grid.getView().getCell(array1[i][j], i);
aRow.style.borderTop = 'none';
} else {
aRow = grid.getView().getCell(i, array1[i][j]);
aRow.style.borderLeft = "none";
}
}
}
}; //在执行load的时候加载
ds_Custom.on('load',function(){
gridSpan(gpCustom, 'row',"cname", '1px solid #DDDDDD');
});

/*与表头对齐*/
.x-grid3-row td,.x-grid3-summary-row td {
padding-right: 0px;
padding-left: 0px;
padding-top: 0px;
padding-bottom: 0px;
}

注:如果合并的行不想显示网格的话,请在网页的css里面加上 下面的样式参数

  

/*去掉行间空白*/
.x-grid3-row {
border-right-width: 1px;
border-left-width: 1px;
border-top-width: 1px;
border-bottom-width: 1px;
}

  

Extjs 3.4 同值合并的更多相关文章

  1. php 按列值合并数据

    /* * PHP按值合并数组 * */ function my_array_merge(&$array1, &$array2) { $result = Array(); foreach ...

  2. PHP按值合并数组

    /** * PHP按值合并数组 * */ function my_array_merge(&$array1, &$array2) { $result = Array(); foreac ...

  3. php将一个二维数组按照某个字段值合并成一维数组,如果有重复则将重复的合并成二维数组

    版权声明:本文为博主原创文章,未经博主允许不得转载. 最近工作中碰到一个问题,用PHP将一个二维数组按照二维数组中的各个项中的某个特定字段值合并成一维数组,如果有重复则将重复的合并成二维数组,生成的二 ...

  4. EasyExcel导出小结:动态标题、标题格式、相同值合并

    1. 实列相关依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel& ...

  5. SQL SERVER 2008 字段值合并

    /** * 通过 FOR XML PATH 语句,可以将字段的值进行合并. **/ CREATE TABLE tb_child ( name ), hobby ) ) go INSERT INTO t ...

  6. Extjs combobox设置默认值

    转载:http://www.54mask.com/extjs-combobox-default-value.html 相信很多人都遇到了在ExtJS框架中设置combo组件默认值的需求,ExtJS框架 ...

  7. JavaScript中Object值合并方法

    原文:https://www.cnblogs.com/fullstack-yang/p/8085206.html ------------------------------------ 前言:在日常 ...

  8. PHP——数组根据某一键值合并

    前言 其实要实现很简单直接foreach,再根据PHP中数组的特性就可以轻松实现. 步骤 这是源数据的格式 $info = [ [ "gname" => "特别关心 ...

  9. java.util.Map按照key值合并的value的Collection 集合中。

    用java实现把多个map的内容合并的一个resultMap中 代码大致如下 /**  * @author Shalf  */ public class MapUtil { /** * 把partMa ...

随机推荐

  1. python 之sqlalchemy many to many

    # -*- coding: utf-8 -*- """ @author: zengchunyun """ from sqlalchemy i ...

  2. C# 内嵌其他程序到自己程序

    写一xxx聊天机器人啊什么的可能会用到这种技术.比如把QQ窗体嵌入自己的winform中其实很简单,调用两个API函数即可. [DllImport("User32.dll ", E ...

  3. dedecms有条件sql注入(x0day)

    https://www.t00ls.net/thread-35569-1-1.html http://localhost/dedecms/plus/advancedsearch.php?mid=1&a ...

  4. go语言学习笔记

    Go语言学习基本类型Bool 取值范围:true,false (不可以用数字代替)Int/uint 根据平台可能为32或64位int8/uint8 长度:1字节 取值范围-128~127/0~255b ...

  5. 对比SerialCommunication和微软的SerialPort,向SerialPort看齐

    SerialCommunication是我综合网上看到的代码稍作修改而成的串口通信类,而SerialPort则是C#的System类库的IO目录Ports子目录下的串口通信类.SerialCommun ...

  6. android——从零开始

     一.JDK(不用安装)1.下载适合的jdk2.配置环境变量 添加一系统边=变量       JAVA_HOME=D:\Java\jdk1.8.0_91      CLASSPATH=.;%JAVA_ ...

  7. C#的7个原则

    C#的七个原则如下: 1.单一职责原则(Single Responsibility Principle, SRP):一个类只负责一个功能领域中的相应职责. 2.开闭原则(Open-Closed Pri ...

  8. JavaScript slice() 方法

    JavaScript slice() 方法  JavaScript Array 对象 实例 在数组中读取元素: var fruits = ["Banana", "Oran ...

  9. Cross join in excel --- Copy from Internet

    Set up the Workbook In this example, there are two tables -- Raw Materials and Packaging -- and each ...

  10. eclipse SE增加Web开发插件;安装配置Apache

    在eclipse SE版本点击"Help"--"Install New Software..."--"Work with"中输入" ...