【jqGrid】翻页获取选中的值
1、实现效果: 点击确定所选按钮之后,获取翻页选中的题库表号

2、关键代码
onSelectAll: function (aRowids, status) {
},
onSelectRow: function (aRowids, status) {
}
 jQuery("#questionindex_table").jqGrid({
            url: '2safety/exam/questionfile/ashx/list.ashx?act=list',
            datatype: "json",
            colNames: ['ID', '题库表号', '文件名称', '发文号', '发文部门', '规章编号', '发文年月'],
            autoWidth: true,
            rowNum: rowNum,
            rowList: rowList,
            rownumbers: true,
            pager: '#pager',
            altRows: true,
            shrinkToFit: false,
            viewrecords: true,
            multiselect: true,
            width: 1030,
            height: 350,
            jsonReader: {
                page: "page",
                total: "total",
                repeatitems: false,
                id: "ID"
            },
            onSelectAll: function (aRowids, status) {
                for (var index = 0; index < aRowids.length; index++) {
                    var str = $("#questionindex_table").jqGrid('getRowData', aRowids[index]).QUESTIONFLAG;
                    var str1 = $("#questionindex_table").jqGrid('getRowData', aRowids[index]);
                    if (status)
                    {
                        if (arr.toString().indexOf(str) <0) {
                            arr.push(str);
                            arr1.push({ id: str1.ID, QUESTIONFLAG: str1.QUESTIONFLAG })
                        }
                    }
                    else
                    {
                        for (var i = 0; i < arr.length; i++) {
                            if (arr[i] == str) {
                                arr.splice(i, 1);
                                arr1.splice(i, 1);
                            }
                        }
                    }
                }
            },
            onSelectRow: function (aRowids, status) {
                var str = $("#questionindex_table").jqGrid('getRowData', aRowids).QUESTIONFLAG;
                var str1 = $("#questionindex_table").jqGrid('getRowData', aRowids);
                if (status) {
                    arr.push(str);
                    arr1.push({ id: str1.ID, QUESTIONFLAG: str1.QUESTIONFLAG })
                }
                else
                {
                    for (var i = 0; i < arr.length; i++)
                    {
                        if(arr[i]==str)
                        {
                            arr.splice(i,1);
                            arr1.splice(i, 1);
                        }
                    }
                }
            },
            colModel: [
                 { name: 'ID', index: 'ID', hidden: true, frozen: true },
                  { name: 'QUESTIONFLAG', index: 'QUESTIONFLAG', width: 80, frozen: true },
                 {
                     name: 'NAME', index: 'NAME', width: 250, frozen: true,
                     formatter: function (value, type, row) {
                         switch (row.ISACTIVE + '') {
                             case '0': str = "<span style=\"color:#999999;text-decoration:line-through;\">" + row.NAME + "</span>"; break;
                             case '1': str = row.NAME; break;
                             default: str = row.NAME; break;
                         }
                         return str;
                     }
                 },
                 { name: 'PUBLISHNO', index: 'PUBLISHNO', width: 150, frozen: true },
                 { name: 'JGNAME', index: 'JGNAME', width: 120, frozen: true },
                 { name: 'REGULATIONS', index: 'REGULATIONS', width: 110 },
                 {
                     name: 'PUBLISHTIME', index: 'PUBLISHTIME', width: 80, align: 'center', formatter: function (cellvalue, options, rowObject) {
                         return parent.setAddTime(cellvalue, 'yyyy-MM-dd');
                     }
                 }
            ]
        });
遗留问题:返回上一页之后,之前选中的标识消失
3、知识点
js数组操作:判断数组中是否存在某个字符串
var arr=[46013,25210,16414];
var str="16414";
if (arr.toString().indexOf(str) <0)
{alert("不存在") }
else
{alert("存在")}
js数组操作:删除数组中某个字符串
var arr=[46013,25210,16414];
arr.splice(0, 1);
alert(arr);//[25210,16414];
4、参考网址:http://my.oschina.net/luckyi/blog/316251
【jqGrid】翻页获取选中的值的更多相关文章
- Jquery判断单选框是否选中和获取选中的值
		第一种:利用选中值判断选中 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ... 
- 基于JQ的多选/全选/反选及获取选中的值
		<!-- author:青芒 --> <!DOCTYPE html> <html lang="en"> <head> <met ... 
- jQuery 实现复选框全选、反选及获取选中的值
		实现复选框全选,反选及获取选中的值: 代码如下: <!doctype html> <html lang="en"> <head> <met ... 
- BootStrapTable获取选中数据值并传参至父页面
		如何实现以下效果呢? 首先,我们先要了解一下BootStrapTable如何获取选中数据的具体值. 如下图所示,怎样选择任意一行,获取其中的数据 一.首先想要选择任意一行,就得必须先有选择框,选择框是 ... 
- jqgrid 翻页记录选中行
		简单的jqgrid列表 $("#list").jqGrid({ url:contextPath + "/getList", postData: data, da ... 
- element-ui table 的翻页记忆选中
		公司中台项目刚开始开发,用了vue+element,需要许多前置调研,table的翻译记忆选中就是其中之一. template: <el-table :ref="tableRef&qu ... 
- 【easyui】--combobox--赋值和获取选中的值
		//初始化下拉选框 $('#communityIdDiv').combobox({ url:basepath+"pushController/queryCommonityName" ... 
- 使用layui框架的select获取选中的值
		在使用时需要注意:select标签的外层需要加上类名".layui-form" 接下来就是根据需求来改变下拉框的内容了,直接给select的option重新赋一次值,记得加上对应的 ... 
- jquery获取选中的值和设置单选扭选中
		<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ... 
随机推荐
- PostgreSQL 循环导出schema的脚本
			需要备份的schema列表 $ cat need_backup_schema.txt pipeline_na_16q3_v4 pipeline_na_16q4_v8 pipeline_na_16q4_ ... 
- php 中文unicode 互转
			/** * $str 原始中文字符串 * $encoding 原始字符串的编码,默认GBK * $prefix 编码后的前缀,默认"&#" * $postfix 编码后的后 ... 
- python元组数据类型讲解
			元组可以被看成是不能改变的列表.列表是动态的,你可以增添,插入,删除,更改列表元素.有时我们需要这样的操作,但是有些时候我们需要保证有些数据是不能被用户或程序更改的.这就是元组的作用. 准确的说,列表 ... 
- python 安装PostgreSQL 模块:psycopg2
			官方资料:http://www.psycopg.org/psycopg/docs/ 安装: yum -y install python-psycopg2 (安装的版本可能是2.0) pip insta ... 
- Codeforces 1236E. Alice and the Unfair Game
			传送门 首先可以注意到对于固定的起点 $S$ ,它最终能走到的终点一定是一段区间 这个用反证法容易证明,假设合法区间存在断点,这个点左右都可以作为终点 那么分成区间断点在起点左边和起点右边讨论一下即可 ... 
- Graph、DFS、BFS
			Graph.java package Graph; import LinearLIst.bag.Bag; import edu.princeton.cs.algs4.In; public class ... 
- 执行sql语句,不依靠实体 获取string值
			IList<string> list2 = Session.CreateSQLQuery(sql.ToString()).List<string>(); 
- 学习笔记--三分法&秦九韶算法
			前言 其实也没什么好说的吧,三分法就是用来求一个单调函数的最值和满足最大值的\(x\),秦九韶算法就是在\(O(N)\)时间内求一个多项式值 怎么用 三分法使用--看这篇:https://www.cn ... 
- electron-vue在npm run build时报错 ⨯ cannot execute cause=fork/exec C:\Users\801\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.5.0\rcedit-ia32.exe: Access is denied.
			问题描述 在electron-vue执行npm run build时报错,错误如下: ⨯ cannot execute cause=fork/exec C:\Users\801\AppData\Loc ... 
- Delphi CloseHandle函数
