我正在使用带有搜索栏和复选框列的Jqgrid。如果我搜索数据并检查,则取消选中。 [英] I am having Jqgrid with search bar and checkbox column.Checkbox get unchecked if I search the data and check.

查看:77
本文介绍了我正在使用带有搜索栏和复选框列的Jqgrid。如果我搜索数据并检查,则取消选中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网格:

$(function(){

$(&## purposeTable")。jqGrid({

ajaxGridOptions:{ cache:false},

url:'../ Handler / MatrateHandler.ashx?Mode =''',

数据类型:'json',

contentType:'application / json; charset = utf-8',

身高:250,

jsonReader:{

root:" ;行,

页面:"页面",

总计:" totalpages",

记录:" totalrecords",

cell:" cell",

id:" id",//带有PK的列的索引

userdata: " userdata",

repeatitems:false

},



colNames:['Key','Select','Purpose Name',],

colModel:[{name:'iKey',index:'iKey',hidden:true,size:10} ,

{

name:'iSelectBrand',index:'iSelectBrand',width:50,align:" center",editable:true,size:10,edittype :复选框,editoptions:{value:" True:False" },

格式化程序:" checkbox",formatoptions:{disabled:false}

},

{name:'vcBrandName',index :'vcBrandName',大小:10}

],

ondblClickRow:function(id){

// getRecordsforEdit();

},

rowNum:1000,

rownumbers:true,

// pager:'#Relativemap',

ignoreCase:true,/ *不区分大小写的搜索* /

sortname:'iId',

sortorder:" asc",

gridview:true,

viewrecords:true,

宽度:250,

标题:'目的权',

身高:250,

loadonce:true ,

editurl:'../ Handler / MaterialHandler.ashx?Mode ='',

loadComplete:function(data){



searchSubGridId(" PurposeTable")

}

});

});





搜索代码:



函数searchSubGridId(tablename){

尝试{



$('#'+ tablename).jqGrid('filterToolbar',{defaultSearch:" cn",searchOnEnter:false,hight: " 300px",enableClear:true});

var search ='gs_';

var idCheckTester = new RegExp(search);

var count = document.getElementsByTagName(" input");

var elm;

for(var i = 0;我< count.length; i ++){

elm = count [i];

if(idCheckTester.test(elm.id)){

var searchId = elm .id;



// document.getElementById(searchId).className =" clsSearch";

document.getElementById(searchId)。 placeholder =" Search";

document.getElementById(searchId).style.height =" 12px";

document.getElementById(searchId).style.left = " 0px";

document.getElementById(searchId).style.position =" absolute";

}

}





}

catch(ex){

document.location.href =' frmSessionManager.html';

}

}

Grid:
$(function () {
$("#PurposeTable").jqGrid({
ajaxGridOptions: { cache: false },
url: '../Handler/MaterialHandler.ashx?Mode=Purpose',
datatype: 'json',
contentType: 'application/json; charset=utf-8',
height: 250,
jsonReader: {
root: "rows",
page: "page",
total: "totalpages",
records: "totalrecords",
cell: "cell",
id: "id", //index of the column with the PK in it
userdata: "userdata",
repeatitems: false
},

colNames: ['Key', 'Select', 'Purpose Name', ],
colModel: [{ name: 'iKey', index: 'iKey', hidden: true, size: 10 },
{
name: 'iSelectBrand', index: 'iSelectBrand', width: 50, align: "center", editable: true, size: 10, edittype: "checkbox", editoptions: { value: "True:False" },
formatter: "checkbox", formatoptions: { disabled: false }
},
{ name: 'vcBrandName', index: 'vcBrandName', size: 10 }
],
ondblClickRow: function (id) {
// getRecordsforEdit();
},
rowNum: 1000,
rownumbers: true,
//pager: '#Relativemap',
ignoreCase: true, /* case insensitive search */
sortname: 'iId',
sortorder: "asc",
gridview: true,
viewrecords: true,
width: 250,
caption: 'Purpose Rights',
height: 250,
loadonce: true,
editurl: '../Handler/MaterialHandler.ashx?Mode=Purpose',
loadComplete: function (data) {

searchSubGridId("PurposeTable")
}
});
});


Code for search:

function searchSubGridId(tablename) {
try {

$('#' + tablename).jqGrid('filterToolbar', { defaultSearch: "cn", searchOnEnter: false, hight: "300px", enableClear: true });
var search = 'gs_';
var idCheckTester = new RegExp(search);
var count = document.getElementsByTagName("input");
var elm;
for (var i = 0; i < count.length; i++) {
elm = count[i];
if (idCheckTester.test(elm.id)) {
var searchId = elm.id;

// document.getElementById(searchId).className = "clsSearch";
document.getElementById(searchId).placeholder = "Search";
document.getElementById(searchId).style.height = "12px";
document.getElementById(searchId).style.left = "0px";
document.getElementById(searchId).style.position = "absolute";
}
}


}
catch (ex) {
document.location.href = 'frmSessionManager.html';
}
}

推荐答案

(function(){
(function () {


(&## purposeTable")。jqGrid({

ajaxGridOptions:{cache :false},

url:'../ Handler / MatrateHandler.ashx?Mode ='',

数据类型:'json',

contentType:'application / json; charset = utf-8',

身高:250,

jsonReader:{

root:" rows",

页面:" page",

总计:" totalpages",

记录:" totalrecords",

cell: " cell",

id:" id",//带有PK的列的索引

userdata:" userdata",

repeatitems:false

},


colNames:['Key','Select','目的名',] ,

colModel:[{name:'iKey',index:'iKey',hidden:true,size:10},

{

name:'iSelectBrand',index:'iSelectBrand',width:50,align:" center",editable:tru e,大小:10,edittype:" checkbox",editoptions:{value:" True:False" },

格式化程序:" checkbox",formatoptions:{disabled:false}

},

{name:'vcBrandName',index :'vcBrandName',大小:10}

],

ondblClickRow:function(id){

// getRecordsforEdit();

},

rowNum:1000,

rownumbers:true,

// pager:'#Relativemap',

ignoreCase:true,/ *不区分大小写的搜索* /

sortname:'iId',

sortorder:" asc",

gridview:true,

viewrecords:true,

宽度:250,

标题:'目的权',

身高:250,

loadonce:true ,

editurl:'../ Handler / MaterialHandler.ashx?Mode ='',

loadComplete:function(data){



searchSubGridId(" PurposeTable")

}

});

});





搜索代码:



函数searchSubGridId(tablename){

尝试{


("#PurposeTable").jqGrid({
ajaxGridOptions: { cache: false },
url: '../Handler/MaterialHandler.ashx?Mode=Purpose',
datatype: 'json',
contentType: 'application/json; charset=utf-8',
height: 250,
jsonReader: {
root: "rows",
page: "page",
total: "totalpages",
records: "totalrecords",
cell: "cell",
id: "id", //index of the column with the PK in it
userdata: "userdata",
repeatitems: false
},

colNames: ['Key', 'Select', 'Purpose Name', ],
colModel: [{ name: 'iKey', index: 'iKey', hidden: true, size: 10 },
{
name: 'iSelectBrand', index: 'iSelectBrand', width: 50, align: "center", editable: true, size: 10, edittype: "checkbox", editoptions: { value: "True:False" },
formatter: "checkbox", formatoptions: { disabled: false }
},
{ name: 'vcBrandName', index: 'vcBrandName', size: 10 }
],
ondblClickRow: function (id) {
// getRecordsforEdit();
},
rowNum: 1000,
rownumbers: true,
//pager: '#Relativemap',
ignoreCase: true, /* case insensitive search */
sortname: 'iId',
sortorder: "asc",
gridview: true,
viewrecords: true,
width: 250,
caption: 'Purpose Rights',
height: 250,
loadonce: true,
editurl: '../Handler/MaterialHandler.ashx?Mode=Purpose',
loadComplete: function (data) {

searchSubGridId("PurposeTable")
}
});
});


Code for search:

function searchSubGridId(tablename) {
try {


('#'+ tablename).jqGrid('filterToolbar',{defaultSearch:" cn", searchOnEnter:false,hight:" 300px",enableClear:true});

var search ='gs_';

var idCheckTester = new RegExp(search);

var count = document.getElementsByTagName(" input");

var elm;

for(var i = 0;我< count.length; i ++){

elm = count [i];

if(idCheckTester.test(elm.id)){

var searchId = elm .id;



// document.getElementById(searchId).className =" clsSearch";

document.getElementById(searchId)。 placeholder =" Search";

document.getElementById(searchId).style.height =" 12px";

document.getElementById(searchId).style.left = " 0px";

document.getElementById(searchId).style.position =" absolute";

}

}





}

catch(ex){

document.location.href =' frmSessionManager.html';

}

}
('#' + tablename).jqGrid('filterToolbar', { defaultSearch: "cn", searchOnEnter: false, hight: "300px", enableClear: true });
var search = 'gs_';
var idCheckTester = new RegExp(search);
var count = document.getElementsByTagName("input");
var elm;
for (var i = 0; i < count.length; i++) {
elm = count[i];
if (idCheckTester.test(elm.id)) {
var searchId = elm.id;

// document.getElementById(searchId).className = "clsSearch";
document.getElementById(searchId).placeholder = "Search";
document.getElementById(searchId).style.height = "12px";
document.getElementById(searchId).style.left = "0px";
document.getElementById(searchId).style.position = "absolute";
}
}


}
catch (ex) {
document.location.href = 'frmSessionManager.html';
}
}


这篇关于我正在使用带有搜索栏和复选框列的Jqgrid。如果我搜索数据并检查,则取消选中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆