type = "hidden" id = "selectedIds" value = "" />
function optGrid(rowId, status){
var ids = $("#selectedIds").val();
ids = status==true ? (ids.indexOf(rowId) == -1? ids + rowId+",":ids) : ids.replace((rowId+","),"");
$("#selectedIds").val(ids);
}
function load_authcode_jqGrid(){
jQuery("#ajax_authcode_table").jqGrid({
url:'ajax-authcode!list.action',
datatype: "json",
colNames:['注册码',"所属企业","当前状态","当前使用/已使用","绑定时间","剩余天数","创建时间",'创建人',"id"],
colModel:[
{name:'authCode',index:'authCode', width:120,sortable:true,search:false},
{name:'company',index:'company', width:120,sortable:true,search:false},
{name:'status',index:'status', width:80,search:false,formatter:statusFormat},
{name:'use',index:'use', width:60,search:false},
{name:'bindDate',index:'bindDate', width:60,search:false},
{name:'days',index:'days', width:60,search:false},
{name:'createDate',index:'createDate', width:80,search:false},
{name:'creater',index:'creater_name', width:80,search:false},
{name:'id',index:'id',hidden:true,search:false}
],
rowNum : 10,
rowList:[10,20,30],
pager : '#ajax_authcode_list_page',
gridComplete:function(){
var dIds=$("#ajax_authcode_table").jqGrid('getDataIDs');
var sIds = $("#selectedIds").val();
for(var i=0;i<dIds.length;i++){
if(sIds.indexOf(dIds[i])!=-1) $("#ajax_authcode_table").jqGrid("setSelection", dIds[i]);
}
$(".ui-jqgrid-bdiv").css("overflow-x","hidden");
jqGridStyle();
},
caption : " 充值码一览",
jsonReader: {
root: "dataRows",
page: "page",
total: "total",
records: "records",
repeatitems : false
},
multiselect : true,
rownumbers:true,
gridview:true,
shrinkToFit:true,
viewrecords: true,
autowidth: true,
height:'auto',
forceFit:true,
onSelectRow:function(rowId, status, e){
optGrid(rowId, status)
},
onSelectAll:function(aRowids, status, e){
for(var i=0;i<aRowids.length;i++){
optGrid(aRowids[i], status);
}
},
loadComplete: function() {
}
});
$(window).on('resize.jqGrid', function() {
jQuery("#ajax_authcode_table").jqGrid('setGridWidth', $("#ajax_authcode_list_row").width());
})
jQuery("#ajax_authcode_table").jqGrid('navGrid', "#ajax_authcode_list_page", {
edit : false,
add : false,
del : false,
search:false
});
};
来自为知笔记(Wiz)