jqGrid pivot获取所有行包括小计数据及原码分析
1.结论:按正常jqGid获取,在中间加入以下代码,即将小计行当成改变为普能行,以便能让'getRowData'方法获取到,第三点会进行原码分析
//get all page grid data,including group count row
getJQAllData:function (jqGridId) {
var o = $("#"+jqGridId);
//get current page data $("#jqGridList").jqGrid('getRowData');
var rows=[];
rows= o.jqGrid('getRowData');
var rowNum = o.jqGrid('getGridParam', 'rowNum'); //get the record amount of current page data
var total = o.jqGrid('getGridParam', 'records'); //get the total records of all page
//reload the all data with no spliting of page,then can get all real data by invoking the function getRowData
o.jqGrid('setGridParam', { rowNum: total }).trigger('reloadGrid'); //here modify temporaily the attributes of "the group count row" ,so that can get the rows by invoking the function getRowData
//will restore after below reloadGrid is invoked
//below three row codes can be executed lonely in IE console
//if want to understand more please refer to the definition of function getRowData in js/jgGrid/jquery.jqGrid.src.js
$('tr[id^="jqGridListghead"]').addClass("jqgrow");//add the class to set it as normal row
$('tr[id^="jqGridListghead"] td').attr("role","gridcell");//add the attributes to set it as normal row
$('tr[id^="jqGridListghead"] td span').remove();//remove unnecessary <span> in the first <td> of the "the group count row",otherwise the got value from <td> will include excessive "<span....>"
rows = o.jqGrid('getRowData'); //get all grid data,and return {} if emtpy
o.jqGrid('setGridParam', { rowNum: rowNum }).trigger('reloadGrid'); //reset the original show
console.log("getJQAllData==>");
console.log(rows);
return (rows instanceof Array)?rows:[];
}
2.获取小计行
3.原码分析:在jquery.jqGrid.src.js第3103行找到方法定义,发现对标题进行了过滤,只需要对相应元素增加属性即可。
getRowData : function( rowid ) {
var res = {}, resall, getall=false, len, j=0;
this.each(function(){
var $t = this,nm,ind;
if(rowid === undefined) {
getall = true;
resall = [];
len = $t.rows.length;
} else {
ind = $($t).jqGrid('getGridRowById', rowid);
if(!ind) { return res; }
len = 2;
}
while(j<len){
if(getall) { ind = $t.rows[j]; }
if( $(ind).hasClass('jqgrow') ) {
$('td[role="gridcell"]',ind).each( function(i) {
nm = $t.p.colModel[i].name;
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
if($t.p.treeGrid===true && nm === $t.p.ExpandColumn) {
res[nm] = $.jgrid.htmlDecode($("span:first",this).html());
} else {
try {
res[nm] = $.unformat.call($t,this,{rowId:ind.id, colModel:$t.p.colModel[i]},i);
} catch (e){
res[nm] = $.jgrid.htmlDecode($(this).html());
}
}
}
});
if(getall) { resall.push(res); res={}; }
}
j++;
}
});
return resall || res;
}
jqGrid pivot获取所有行包括小计数据及原码分析的更多相关文章
- Spring IOC 容器源码分析 - 获取单例 bean
1. 简介 为了写 Spring IOC 容器源码分析系列的文章,我特地写了一篇 Spring IOC 容器的导读文章.在导读一文中,我介绍了 Spring 的一些特性以及阅读 Spring 源码的一 ...
- java使用websocket,并且获取HttpSession,源码分析
转载请在页首注明作者与出处 http://www.cnblogs.com/zhuxiaojie/p/6238826.html 一:本文使用范围 此文不仅仅局限于spring boot,普通的sprin ...
- jqgrid 获取所有行数据
如何获取jqgrid所有数据? 通过 getRowData() 方法获得当前行数据 //获取所有行数据,是一个json对象集合 var rowArr= $("#jqGrid").g ...
- JS获取网页属性包括宽、高等
JS获取网页属性包括宽.高等. function getInfo() { // www.jbxue.com var s = ""; s += " 网页可见区域宽:&q ...
- inux关于readlink函数获取运行路径的小程序
inux关于readlink函数获取运行路径的小程序 相关函数: stat, lstat, symlink 表头文件: #include <unistd.h> 定义函数:int re ...
- 微信小程序开发——获取小程序带参二维码全流程
前言: 想要获取微信小程序带参数二维码,如这种: 官方文档只说了获取小程序码和二维码的三种接口及调用(参考链接:https://developers.weixin.qq.com/miniprogram ...
- python excel操作 练习-#操作单列 #操作A到C列 #操作1到3行 #指定一个范围遍历所有行和列 #获取所有行 #获取所有列
##操作单列#操作A到C列#操作1到3行#指定一个范围遍历所有行和列#获取所有行#获取所有列 #coding=utf-8 from openpyxl import Workbook wb=Workbo ...
- 通过kfed自动获取磁盘信息的小脚本
通过kfed自动获取磁盘信息的小脚本 编译KFED [oracle@rac lib]$cd $ORACLE_HOME/rdbms/lib [oracle@rac lib]$ pwd /u01/app/ ...
- 获取不同机型微信小程序状态栏+导航栏高度
获取不同机型微信小程序状态栏+导航栏高度 一. 前言 很多时候我们开发微信小程序,都需要先知道状态栏和导航栏的高度,才能去做其他功能 二. 获取微信小程序状态栏高度 用wx.getSystemInfo ...
随机推荐
- Ubuntu 14.10 下Spark on yarn安装
1 服务器分布 服务器 说明 192.168.1.100 NameNode 192.168.1.101 DataNode 192.168.1.102 DataNode 2 软件环境 2.1 安装JDK ...
- 【IIS错误】IIS各种错误
IIS简介 当用户试图通过HTTP或文件传输协议(FTP)访问一台正在运行Internet信息服务 (IIS)的服务器上的内容时,IIS返回一个表示该请求的状态的数字代码.该状态代码 记录在IIS日志 ...
- docker下centos安装ping命令
https://blog.csdn.net/king_gun/article/details/78423115 [问题] 从docker hub上拉取到则镜像centos:6.7在执行ping命令是报 ...
- rabbitmq的vhost与用户管理(转)
原文地址:https://blog.csdn.net/leisure_life/article/details/78707338 当我们在创建用户时,会指定用户能访问一个虚拟机,并且该用户只能访问该虚 ...
- MongoDb进阶实践之一 如何在Linux系统上安装和配置MongoDB
转载来源:https://www.cnblogs.com/PatrickLiu/p/8630151.html 一.NoSQL数据简介 1.NoSQL概念 NoSQL(NoSQL = Not Only ...
- Hibernate c3p0的整合
Hibernate整合c3p0 Hibernate中可以使用默认jdbc连接池,但是无论功能还是性能都不如c3p0 在pom添加jar包: <!-- hibernate-c3p0 --> ...
- 第16课 右值引用(3)_std::forward与完美转发
1. std::forward原型 template <typename T> T&& forward(typename std::remove_reference< ...
- ES6核心内容讲解
ECMAScript 6(以下简称ES6)是JavaScript语言的下一代标准.因为当前版本的ES6是在2015年发布的,所以又称ECMAScript 2015. 也就是说,ES6就是ES2015. ...
- Delphi7 中文汉字转网址格式 Utf8编码转换(淘宝搜索中文转网址)
function HttpEncode(S:AnsiString):string; var P:^Byte; I:Cardinal; begin Result:=''; P:=@S[1 ...
- Delphi获取其他exe程序版本号
delphi获取Exe文件版本信息的函数 Type TFileVersionInfo = Record FixedInfo:TVSFixedFileInfo; {版本信息} CompanyName:S ...