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. Django--django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE

    Django序列化时遇到错误: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESP ...

  2. DS树+图综合练习--带权路径和

    题目描述 计算一棵二叉树的带权路径总和,即求赫夫曼树的带权路径和. 已知一棵二叉树的叶子权值,该二叉树的带权案路径和APL等于叶子权值乘于根节点到叶子的分支数,然后求总和.如下图中,叶子都用大写字母表 ...

  3. Eclipse安装Markdown插件

    Markdown Editor 安装Markdown插件可以实现 .md 和 .txt 文件的 Markdown 语法高亮,并提供 HTML 预览. 因为之前没有安装过别的插件,eclipse上安装插 ...

  4. Springboot监控之二:Spring Boot Admin对Springboot服务进行监控

    概述 Spring Boot 监控核心是 spring-boot-starter-actuator 依赖,增加依赖后, Spring Boot 会默认配置一些通用的监控,比如 jvm 监控.类加载.健 ...

  5. IDC:IDC 清单

    ylbtech-IDC:IDC 清单 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbte ...

  6. [VS2013]常见异常修正

    未能加载文件或程序集“Microsoft.SqlServer.Management.Sdk.Sfc, Version=11.0.0.0, Culture=neutral, PublicKeyToken ...

  7. SFINAE简单实例

    SFINAE(Substitution failure is not an error),是C++11以来推出的一个重要概念,这里,只是简单举一个例子,可能会有人需要. // 添加 scalar nu ...

  8. 方法 - ShellCode测试

    机器码->汇编 1 // ShellCode测试.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <windo ...

  9. [UE4]基于物理的材质

    基于物理的材质可以产生更准确并且通常更加自然的外观,在所有照明环境中都可以同样完美地工作! 官方说明

  10. 总结一下连日来在MAC下被Python3设下的坑

    当时的情况:mac下自带python2, 1.安装pyhon3: 首次从官网下载了安装包安装,安装目录在/Library/Frameworks/Python.framework/Versions/3. ...