原文地址;http://www.cnblogs.com/josechuanmin/archive/2013/05/19/3087138.html
在jqGrid中设置multiselect: true可以实现全选的操作,但怎么设置被选中的checkbox里面的值呢,做法如下:
jQuery("#listTable").jqGrid({
url: 'queryList.do',
datatype: 'json',
colNames: ['','编号','姓名'],
colModel: [
{
name: 'MY_ID',
index: 'MY_ID',
sortable: false,
width: '0%',
hidden:true
},
{
name: 'MY_NO',
index:'MY_NO',
sortable: false,
align:'center',
width:'10%'
},
{
name: 'NAME',
index:'NAME',
sortable: false,
align:'center',
width:'10%'
}
],
page: 1,
rowNum: 10,
rowList: [10, 20, 30],
pager: '#listPage',
multiselect: true,
sortname: 'MY_NO',
viewrecords: true,
sortorder: "desc",
jsonReader: {
repeatitems: false
},
width: "100%",
height: '100%',
gridComplete: function() {
var rowIds = jQuery("#listTable").jqGrid('getDataIDs');
for(var k=0; k<rowIds.length; k++) {
var curRowData = jQuery("#listTable").jqGrid('getRowData', rowIds[k]);
var curChk = $("#"+rowIds[k]+"").find(":checkbox");
curChk.attr('name', 'checkboxname'); //给每一个checkbox赋名字
curChk.attr('value', curRowData['MY_ID']); //给checkbox赋值
curChk.attr('title', curRowData['NAME'] ); //给checkbox赋予额外的属性值