1, achieve the effect: Click to confirm the selected button, get the page number of the selected question sheet
2. Key code
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 ', ' Question Bank list ', ' File name ', ' Document Number ', ' dispatch department ', ' regulatory number ', ' Posting Date '], 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(varindex = 0; Index < arowids.length; index++) { varstr = $ ("#questionindex_table"). Jqgrid (' GetRowData ', Arowids[index]). Questionflag; varSTR1 = $ ("#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(vari = 0; i < arr.length; i++) { if(Arr[i] = =str) {Arr.splice (i,1); Arr1.splice (i,1); }}}}, Onselectrow: function(arowids, status) {varstr = $ ("#questionindex_table"). Jqgrid (' GetRowData ', Arowids). Questionflag; varSTR1 = $ ("#questionindex_table"). Jqgrid (' GetRowData '), Arowids); if(status) {Arr.push (str); Arr1.push ({Id:str1.ID, questionflag:str1. Questionflag})}Else { for(vari = 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; } returnstr; }}, {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) {returnParent.setaddtime (Cellvalue, ' yyyy-mm-dd ')); } } ] });
Legacy Issue: The previously selected identity disappears after you return to the previous page
3, Knowledge points
JS Array operation: Determine if a string exists in the array
var arr=[46013,25210,16414];
var str= "16414";
if (arr.tostring (). indexOf (str) <0)
{Alert ("does not exist")}
Else
{alert ("exists")}
JS Array operation: Delete a string in an array
var arr=[46013,25210,16414];
Arr.splice (0, 1);
Alert (arr);//[25210,16414];
4. Reference website: http://my.oschina.net/luckyi/blog/316251
"Jqgrid" page to get the selected value