jqGrid 获取多级标题表头
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 获取多级标题表头的更多相关文章
- php正则获取网页标题、关键字、网页描述代码
php正则获取网页关键字,代码如下: function get_keywords($html) { $html=strtolower($html); preg_match("@<hea ...
- c#使用DocX添加多级标题
博客转移到 http://jacean.github.io/ 继续分享编程经验 先上效果.可以生成多级标题,但是不能生成1,1.1,1.2这样的自动序列, 只是这样的效果. 实现方法是给Paragra ...
- jqgrid 获取当前页码
jqgrid 获取当前页码 $('#gridTable').getGridParam('page'); /** *刷新,jqGrid刷新当前列表页代码 */ function refresh(url) ...
- iOS之UIWebView无法获取web标题
最近遇到了一个问题,就是在UIWebView的代理方法里,执行document.title的js代码无法获取网页标题,代码如下: - (void)webViewDidFinishLoad:(UIWeb ...
- Python2获取网页标题
Python获取网页标题 使用Python2.x的urllib2和lxml,速度应该还快于BeautifulSoup4(话说回来,为什么大家都要用BS4呢?一个XPATH不就完了吗) 没有安装过的,用 ...
- Qt实现表格控件-支持多级列表头、多级行表头、单元格合并、字体设置等
目录 一.概述 二.效果展示 三.定制表头 1.重写数据源 2.重写QHeaderView 四.设置属性 五.相关文章 原文链接:Qt实现表格控件-支持多级列表头.多级行表头.单元格合并.字体设置等 ...
- el-table的花样需求---表格加图片、加音频、加序号、多级动态表头
elemnet-ui组件库大家应该不陌生,在展示多条结构类似的数据方面,el-table可谓扛把子,不仅可以把数据展示的整齐,还支持排序.筛选或其他自定义操作.那么,除了上述的基本功能外,你还遇到过哪 ...
- el-table 表格加图片、加音频、加序号、多级动态表头
elemnet-ui组件库大家应该不陌生,在展示多条结构类似的数据方面,el-table可谓扛把子,不仅可以把数据展示的整齐,还支持排序.筛选或其他自定义操作.那么,除了上述的基本功能外,你还遇到过哪 ...
- PyQt(Python+Qt)学习随笔:QTableView的标题表头相关属性
老猿Python博文目录 老猿Python博客地址 一.概述 在Qt Designer中,对于表视图QTableView,在属性在下面有专门一栏列出了跟标题相关的属性,如图: 这些属性并不是QTabl ...
随机推荐
- Xshell里连接VirtualBox里的Centos7
关闭虚拟机 右键虚拟机->设置->网络,连接方式选择NAT,如下图: 3.在Xshell里连接即可.
- jquery zTree异步搜索的例子--搜全部节点
参考博客: https://segmentfault.com/a/1190000004657854 https://blog.csdn.net/houpengfei111/article/detail ...
- Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则
微服务网关是socket长连接与支付公司对接,该网关需要提供http接口给内部系统调用,当socket没有建立连接时(网关服务的高可用是haProxy搭建的,有些服务的socket可能未连上支付公司) ...
- dubbo项目部署遇到的问题
部署的项目结构如下: [图片] 1 Socket >>>相关的报错 检查下zookeeper的服务端cmd和客户端cmd是否起来了 2 jdbc.DataSourceProperti ...
- [UE4]函数参数引用
函数传递的变量可以当做正常的内部变量使用,而不需要把函数变量赋值给新创建一个内部变量.
- 博客搬入CNBLOG
由于无法改变的事实,原来在163blog中的博文永久停止更新.但博文内容仍然保留,在此也谢谢网易不杀之恩.毕竟那都是博主们一个字一个字的敲出来的心血.以后新的内容会在CNBLOG中进行更新.立贴为证. ...
- 【 MAKEFILE 编程基础之三】详解 MAKEFILE 变量的定义规则使用!
本站文章均为 李华明Himi 原创,转载务必在明显处注明: 转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/gcc-makefile/770.html ...
- SAS 数据集生成map 文件
OPTIONS NOCENTER PS=MAX LS=MAX; LIBNAME S '.'; DATA A; INPUT X $ @@; CARDS;A1 A2 A3 B1 B2 B3 ...
- 您无法登陆系统。原因可能是您的用户记录或所属的业务部门在Microoft Dynamics CRM中已被禁用
问题发生在CRM 4.0 上 1 用户所在办事处及办事处上级被禁用. 2 如果已经重新启用了,还是报这个错误. 可以把停用的办事处及相关下级再重新--停用--启用一次试试. 3 如果还是报错,查看是否 ...
- (转)C#动态webservice调用接口
原文地址:http://www.cnblogs.com/zouhao/p/6236785.html ,此处仅测试了使用Http post请求调用webservice 调用类: using Syst ...