1.jgGrid没有提供此方法获取如下标题

2.实现代码

getHeaders:function(){
var headers=[],temptrs=[];
//select the group header tr
//th=$('th[class="ui-state-default ui-th-column-header ui-th-ltr"]'); //console.log(th);
//use for merge the cell in excel
temptrs=$('tr[class^="ui-jqgrid-labels"]');
var rowspan=0;
var colspan=0;
for(var i=0;i<temptrs.length;i++){
var tr={};
var ths=[];
//go to group header row
//th=th.first().parent();
//remove the non-group-header-th html
//console.log(th.html());
//tr=th.clone();
//tr.append(th.children());
//tr.find("th").children().remove();
//console.log(tr); temptrs.eq(i).find("th").each(function(){
//console.log(this);
//console.log($(this).attr("rowspan"));
//console.log($(this).attr("colspan"));
//console.log($(this).text());
rowspan=typeof($(this).attr("rowspan"))=="undefined"?0:$(this).attr("rowspan");
colspan=typeof($(this).attr("colspan"))=="undefined"?0:$(this).attr("colspan"); var temth={};
temth["cellvalue"]=$(this).text().trim();
temth["rowspan"]=rowspan;
temth["colspan"]=colspan;
ths.push(temth);
}); tr["row"]=ths;
headers.push(tr); //var th=$('th[class="ui-state-default ui-th-column-header ui-th-ltr"]').first().parent().html();
} console.log("get headers==>");
console.log(headers);
return headers; }

3.输出结果:

"[{
 "row":
  [{"cellvalue":"","rowspan":0,"colspan":0},
  {"cellvalue":"","rowspan":0,"colspan":0},
  {"cellvalue":"us","rowspan":0,"colspan":"2"},
  {"cellvalue":"uk","rowspan":0,"colspan":"2"},
  {"cellvalue":"ch","rowspan":0,"colspan":"2"},
  {"cellvalue":"ck","rowspan":0,"colspan":"2"},
  {"cellvalue":"au","rowspan":0,"colspan":"2"},
  {"cellvalue":"ja","rowspan":0,"colspan":"2"},
  {"cellvalue":"cn","rowspan":0,"colspan":"2"},
  {"cellvalue":"","rowspan":0,"colspan":0},
  {"cellvalue":"","rowspan":0,"colspan":0}]
 },{
 "row":
  [{"cellvalue":"group","rowspan":0,"colspan":0},
  {"cellvalue":"name","rowspan":0,"colspan":0},
  {"cellvalue":"合计汇总","rowspan":0,"colspan":0},
  {"cellvalue":"Count","rowspan":0,"colspan":0},
  {"cellvalue":"合计汇总","rowspan":0,"colspan":0},
  {"cellvalue":"Count","rowspan":0,"colspan":0},
  {"cellvalue":"合计汇总","rowspan":0,"colspan":0},
  {"cellvalue":"Count","rowspan":0,"colspan":0},
  {"cellvalue":"合计汇总","rowspan":0,"colspan":0},
  {"cellvalue":"Count","rowspan":0,"colspan":0},
  {"cellvalue":"合计汇总","rowspan":0,"colspan":0}]
}]

返回json数组,row为标题行,最里层的对象为一个单元格,并标识占行列,可用于导出excel时单元格合并。

jqGrid 获取多级标题表头的更多相关文章

  1. php正则获取网页标题、关键字、网页描述代码

    php正则获取网页关键字,代码如下: function get_keywords($html) { $html=strtolower($html); preg_match("@<hea ...

  2. c#使用DocX添加多级标题

    博客转移到 http://jacean.github.io/ 继续分享编程经验 先上效果.可以生成多级标题,但是不能生成1,1.1,1.2这样的自动序列, 只是这样的效果. 实现方法是给Paragra ...

  3. jqgrid 获取当前页码

    jqgrid 获取当前页码 $('#gridTable').getGridParam('page'); /** *刷新,jqGrid刷新当前列表页代码 */ function refresh(url) ...

  4. iOS之UIWebView无法获取web标题

    最近遇到了一个问题,就是在UIWebView的代理方法里,执行document.title的js代码无法获取网页标题,代码如下: - (void)webViewDidFinishLoad:(UIWeb ...

  5. Python2获取网页标题

    Python获取网页标题 使用Python2.x的urllib2和lxml,速度应该还快于BeautifulSoup4(话说回来,为什么大家都要用BS4呢?一个XPATH不就完了吗) 没有安装过的,用 ...

  6. Qt实现表格控件-支持多级列表头、多级行表头、单元格合并、字体设置等

    目录 一.概述 二.效果展示 三.定制表头 1.重写数据源 2.重写QHeaderView 四.设置属性 五.相关文章 原文链接:Qt实现表格控件-支持多级列表头.多级行表头.单元格合并.字体设置等 ...

  7. el-table的花样需求---表格加图片、加音频、加序号、多级动态表头

    elemnet-ui组件库大家应该不陌生,在展示多条结构类似的数据方面,el-table可谓扛把子,不仅可以把数据展示的整齐,还支持排序.筛选或其他自定义操作.那么,除了上述的基本功能外,你还遇到过哪 ...

  8. el-table 表格加图片、加音频、加序号、多级动态表头

    elemnet-ui组件库大家应该不陌生,在展示多条结构类似的数据方面,el-table可谓扛把子,不仅可以把数据展示的整齐,还支持排序.筛选或其他自定义操作.那么,除了上述的基本功能外,你还遇到过哪 ...

  9. PyQt(Python+Qt)学习随笔:QTableView的标题表头相关属性

    老猿Python博文目录 老猿Python博客地址 一.概述 在Qt Designer中,对于表视图QTableView,在属性在下面有专门一栏列出了跟标题相关的属性,如图: 这些属性并不是QTabl ...

随机推荐

  1. ALGO-17_蓝桥杯_算法训练_乘积最大(DP)

    问题描述 今年是国际数学联盟确定的“——世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友XZ也有幸得以参加. ...

  2. 【占位符替换】替换String中的占位符标志位{placeholder}

    概述 占位符替换, 占位符表示为:{placeholder}; 示例:替换如下{xxx}占位符中的内容 "名字:{name},年龄:{age},学校:{school}" 提供了两种 ...

  3. 峰Redis学习(6)Redis 数据结构(sorted-set的操作)

    第六节:Redis 数据结构之sorted-set 类型 存储Sorted-Set Sorted-Set和Set的区别   Sorted-Set中的成员在集合中的位置是有序的   存储Sorted-s ...

  4. 使用jquery.mCustomScrollbar自定义滚动条(1)

    参考博客:https://blog.csdn.net/cdnight/article/details/41351505 api网址:http://manos.malihu.gr/jquery-cust ...

  5. spring4.0之六:Generic Qualifier(泛型限定)

    Spring 4.0已经发布RELEASE版本,不仅支持Java8,而且向下兼容到JavaSE6/JavaEE6,并移出了相关废弃类,新添加如Java8的支持.Groovy式Bean定义DSL.对核心 ...

  6. js堆和栈

    一.栈 栈:英文为“stack”: 定义:一种存放数据的内存区域: 特点: ①LIFO,后进先出: 可视化描述: ②调用栈,函数或者子例程像堆积木一样存放,以实现层层调用: 函数调用形成一个栈帧: f ...

  7. 廖雪峰Java2面向对象编程-6Java核心类-1字符串和编码

    Java的字符串用String表示 1.String特点: 可以直接使用"..."表示一个字符串,不强制使用new String 内容不可变 String s1 = "h ...

  8. 倒数第N个字符串

    给定一个完全由小写英文字母组成的字符串等差递增序列,该序列中的每个字符串的长度固定为 L,从 L 个 a 开始,以 1 为步长递增.例如当 L 为 3 时,序列为 { aaa, aab, aac, . ...

  9. vue 路由 以及默认路由跳转

    https://router.vuejs.org/ vue路由配置: 1.安装 npm install vue-router --save / cnpm install vue-router --sa ...

  10. HibernateUtil工具类的使用

    为了简化代码的重复性,使用HibernateUtil工具类对Hibernate有关的代码进行整合 主要实现有,getSessionFactory(),getSession(),closeSession ...