先定义:    var SelectRowIndx;

然后加入以下属性:

        multiselect: true,
onSelectRow: function () {
SelectRowIndx = GetJqGridRowIndx("#" + this.id);
},
gridComplete: function () {
$("#" + this.id).jqGrid('setSelection', SelectRowIndx);
}

举例:

<script type="text/javascript">
$(function () {
GetGrid();
}) //加载表格
function GetGrid() {
var SelectRowIndx;
$("#gridTable").jqGrid({
url: "@Url.Content("~/School/ClassInfoes/GridPageListJson")",
datatype: "json",
height: $(window).height() - 149,
autowidth: true,
colModel: [
{ label: 'Id', name: 'id', index: 'id', width: 0, align: 'left', sortable: true, hidden: true },
{ label: '所属学校', name: 'schoolname', index: 'schoolname', width: 120, align: 'center', sortable: true },
{ label: '班级编码', name: 'classcode', index: 'classcode', width: 70, align: 'center', sortable: true },
{ label: '院系部', name: 'departname', index: 'departname', width: 50, align: 'center', sortable: true },
{ label: '入学年份', name: 'enteryear', index: 'enteryear', width: 50, align: 'center', sortable: true },
{ label: '毕业年份', name: 'graduateyear', index: 'graduateyear', width: 50, align: 'center', sortable: true },
{ label: '当前所在年级', name: 'currentgradename', index: 'currentgradename', width: 50, align: 'center', sortable: true },
{ label: '当前所属班级', name: 'currentclassname', index: 'currentclassname', width: 50, align: 'center', sortable: true },
{ label: '班级教室', name: 'classroom', index: 'classroom', width: 50, align: 'center', sortable: true },
{ label: '毕业年级', name: 'graduategradename', index: 'graduategradename', width: 50, align: 'center', sortable: true },
{ label: '班主任', name: 'classteachername', index: 'classteachername', width: 50, align: 'center', sortable: true },
{ label: '班长', name: 'monitername', index: 'monitername', width: 50, align: 'center', sortable: true },
{
label: '是否毕业', name: 'flaggraduate', index: 'flaggraduate', width: 50, align: 'center', sortable: true,
formatter: function (cellvalue, options, rowObject) {
if (cellvalue == true) return "<font color='red'>是</font>";
if (cellvalue == false) return "<font color='green'>否</font>";
}
},
{
label: '创建日期', name: 'createdate', index: 'createdate', width: 100, align: 'center', sortable: true,
formatter: function (cellvalue, options, rowObject) {
return formatDate(cellvalue, 'yyyy-MM-dd');
}
},
{ label: '创建者', name: 'createusername', index: 'createusername', width: 50, align: 'center', sortable: true },
{
label: '修改日期', name: 'modifydate', index: 'modifydate', width: 100, align: 'center', sortable: true,
formatter: function (cellvalue, options, rowObject) {
return formatDate(cellvalue, 'yyyy-MM-dd');
}
},
{ label: '修改者', name: 'modifyusername', index: 'modifyusername', width: 50, align: 'center', sortable: true },
{
label: '学生列表', name: 'id', index: 'id', width: 80, align: "center", sortable: false,
formatter: function (cellvalue, options, rowObject) {
var id = rowObject['id']
return "<button onclick=\"AddTabMenu('530b9428-25d9-4166-9dc2-ea994b90cdd6', '/School/Students/StudentsList?id=" + id + "', '学生管理', 'group.png','true',true)\"> 点击我</button>";
}
},
],
pager: "#gridPager",
sortname: 'classcode',
sortorder: 'asc',
rownumbers: true,
shrinkToFit: false,
gridview: true,
multiselect: true,
onSelectRow: function () {
SelectRowIndx = GetJqGridRowIndx("#" + this.id);
},
gridComplete: function () {
$("#" + this.id).jqGrid('setSelection', SelectRowIndx);
}
});
}
//新增
function btn_add() {
var url = "/School/ClassInfoes/Form";
openDialog(url, "Form", "新增班级数据表", 770, 395, function (iframe) {
top.frames[iframe].AcceptClick();
});
}
//编辑
function btn_edit() {
var KeyValue = GetJqGridRowValue("#gridTable", "id");
if (IsChecked(KeyValue)) {
var url = "/School/ClassInfoes/Form?KeyValue=" + KeyValue;
openDialog(url, "Form", "编辑班级数据表", 770, 395, function (iframe) {
top.frames[iframe].AcceptClick();
});
}
} //批量添加班级
function btn_autoadd() {
var url = "/School/ClassInfoes/AutoAddClassInfoes";
openDialog(url, "AutoAddClassInfo", "批量添加班级", 770, 395, function (iframe) {
top.frames[iframe].AcceptClick();
});
} //删除
function btn_delete() {
var KeyValue = GetJqGridRowValue("#gridTable", "id");
if (IsDelData(KeyValue)) {
var delparm = 'KeyValue=' + KeyValue;
delConfig('/School/ClassInfoes/DeleteClassInfoes', delparm, KeyValue.split(",").length);
}
}
//明细
function btn_detail() {
var KeyValue = GetJqGridRowValue("#gridTable", "id");
if (IsChecked(KeyValue)) {
var url = "/School/ClassInfoes/Detail?KeyValue=" + KeyValue;
Dialog(url, "Detail", "班级数据表明细", 820, 500, function (iframe) {
top.frames[iframe].AcceptClick();
});
}
}
//刷新
function windowload() {
$("#gridTable").trigger("reloadGrid"); //重新载入
}
</script>

jqgrid定义多选操作的更多相关文章

  1. JS实战 · 复选框全选操作

    思路: 1.获取被选中checkbox,通过checked属性的状态完成: 2.获取被选中的checkbox的value值: 3.求所有value的和sum: 4.定义span区域存储和sum:   ...

  2. AngularJs 简单实现全选,多选操作

    很多时候我们在处理CURD(增删改查)的时候需要实现批量操作数据,这时候就必须使用多选操作. Angular 中实现如下(当然还有很多种比笔者写的更好的方法,这里只是简单的实现.) demo 演示地址 ...

  3. ListView多选操作模式详解CHOICE_MODE_MULTIPLE与CHOICE_MODE_MULTIPLE_MODAL

    这篇文章我们将详细的介绍如何实现ListView的多选操作,文中将会纠正在使用ListViewCHOICE_MODE_MULTIPLE或者CHOICE_MODE_MULTIPLE_MODAL时容易犯的 ...

  4. JavaScript jQuery 中定义数组与操作及jquery数组操作

    首先给大家介绍javascript jquery中定义数组与操作的相关知识,具体内容如下所示: 1.认识数组 数组就是某类数据的集合,数据类型可以是整型.字符串.甚至是对象Javascript不支持多 ...

  5. Android在listview添加checkbox实现单选多选操作问题(转)

    转自:http://yangshen998.iteye.com/blog/1310183 在Android某些开发需求当中,有时候需要在listveiw中加入checkbox实现单选,多选操作.表面上 ...

  6. GridControl表头全选操作实现之最优方法

    突然发现很久没有写博客了. 昨天整了个Windows Live Writer 就为了以后好好写写博客. 所以,开始咯. 为了积累,也为了分享. 之前在博客园中看到一篇文章:<Winform分页控 ...

  7. Android在listview添加checkbox实现单选多选操作问题

    android根据View的不同状态更换不同的背景http://www.eoeandroid.com/thread-198029-1-1.html android 模仿朋友网推出的菜单效果[改进版]h ...

  8. java: Comparable比较器,定义二叉操作类

    //定义二叉操作类 class BinaryTree{ class Node{ private Node left; //左指数 private Node right; //右指数 private C ...

  9. JavaScript jQuery 中定义数组与操作及jquery数组操作 http://www.jb51.net/article/76601.htm

    首先给大家介绍javascript jquery中定义数组与操作的相关知识,具体内容如下所示: 1.认识数组 数组就是某类数据的集合,数据类型可以是整型.字符串.甚至是对象Javascript不支持多 ...

随机推荐

  1. Pop3_解决PKIX:unable to find valid certification path to requested target 的问题

    最近有公司pop3协议接收pp邮箱出现异常,连不上服务器,错误内容: e: sun.security.validator.ValidatorException: PKIX path building ...

  2. navicat远程连接mysql

      转载:http://blog.sina.com.cn/s/blog_84485e540101178p.html   ERROR 1130: Host '192.168.1.81' is not a ...

  3. [CareerCup] 16.3 Dining Philosophers 哲学家聚餐问题

    16.3 In the famous dining philosophers problem, a bunch of philosophers are sitting around a circula ...

  4. 通过button返回一个action,跳转到一个view

    可以参考采购单的右侧按钮的写法. 简单讲,就是先通过xmlid获取到action_id,继而获取到action,修改action的相关信息,然后将结果返回,即可以实现跳转. mod_obj = sel ...

  5. javax.servlet.jsp cannot be resolved to a type

    参考链接 :http://www.tuicool.com/articles/7Njmqy

  6. Unique Binary Search Trees

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  7. div半透明背景,文字不透明

    background: rgba(255, 255, 255, 0.8) !important; /* IE无效,FF有效 */ background: #fff; filter: alpha(opa ...

  8. zk label控件内容换行

    Label控件本身无法换行,不过div却可以,只要设置了div的宽度,那么就想如果在Label控件外套个div会怎样,结果可喜可乐: <div width="80px"> ...

  9. SQL server 子查询、设置主键外键、变量及变量查询

    一.子查询 子查询,又叫做嵌套查询. 将一个查询语句做为一个结果集供其他SQL语句使用,就像使用普通的表一样,被当作结果集的查询语句被称为子查询. 子查询有两种类型: 一种是只返回一个单值的子查询,这 ...

  10. iOS CUICatalog: Invalid asset name supplied: (null)

    iOS开发出现CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000 原因: 你用了这个方 ...