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 ...
 
随机推荐
- IDEA创建简单servlet程序
			
创建项目 创建完后的目录结构为: web项目配置 在WEB-INF目录下新建两个文件夹,分别命名未classes和lib(classes目录用于存放编译后的class文件,lib用于存放依赖的jar包 ...
 - vue-router总结
			
之前写过一篇关于vue-router的文章,主要是介绍怎么结合cli2在项目中使用vue-router,比较的简单,今天想结合cli3来总结一下vue-router的具体用法. cli3 在介绍vue ...
 - mina2中的session
			
简介 session类图 Mina每建立一个连接同时会创建一个session对象,用于保存这次读写需要用到的所有信息.从抽象类AbstractIoSession中可以看出session具有如下功能: ...
 - go语言学习--语法糖
			
语法糖(Syntactic sugar),也译为糖衣语法,是由英国计算机科学家彼得·约翰·兰达(Peter J. Landin)发明的一个术语,指计算机语言中添加的某种语法,这种语法对语言的功能并没有 ...
 - 无法定位序数****于动态链接库LIBEAY32.dll上
			
问题出现原因: GNS3打开出现问题 尝试的方法如下: 创建脚本: @echo 开始注册 copy libeay32.dll %windir%\system32 regsvr32 %windir%\s ...
 - VLAN    IEEE802.1Q
			
一. VLAN产生原因-广播风暴 传统的局域网使用的是HUB,HUB只有一根总线,一根总线就是一个冲突域.所以传统的局域网是一个扁平的网络,一个局域网属于同一个冲突域.任何一台主机发出的报文都会被同一 ...
 - linux下的进程信息管理
 - jdbc连接池&改进dbUtil成C3P0Util
			
一.jdbc连接池 1.连接池的存在理由 前面介绍的dbUtils工具类虽然实现了一个对jdbc的简单封装.但它依旧采取从驱动管理获取连接 (DriverManager.getConnection ...
 - mono_image_open_from_data_with_name原型
			
mono4.5 https://github.com/Unity-Technologies/mono 查看mono源码: //PATH: /mono/metadata/image.c MonoImag ...
 - 递归锁,event事件和信号量
			
锁通常被用来实现对共享资源的同步访问.为每一个共享资源创建一个Lock对象,当你需要访问该资源时,调用acquire方法来获取锁对象(如果其它线程已经获得了该锁,则当前线程需等待其被释放),待资源访问 ...