请问jqGrid怎么动态的改变里边的列
请问jqGrid怎么动态的改变里边的列,我是想在窗口最大化的时候将jqGrid中的所有列显示出来,在窗口最小化的时候还原到原来的列,比如我原来只显示两列,窗口最大化的时候...
请问jqGrid怎么动态的改变里边的列,我是想在窗口最大化的时候将jqGrid中的所有列显示出来,在窗口最小化的时候还原到原来的列,比如我原来只显示两列,窗口最大化的时候显示5列,最小化的时候又是2列,因为我有多个jqGrid,每个jqGrid中的列数都不一样,能不能帮我想想办法,如果问题能解决,我会给你再加分的,谢谢你了
asdf 展开
asdf 展开
1个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jqgridtest</title>
<link rel="stylesheet" type="text/css" media="screen" href="/js/jqgrid/themes/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/js/jqgrid/themes/redmond/jquery-ui-1.7.1.custom.css" />
<script src="/js/jqgrid/js/jquery.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var initdata = [
{no:"1",n:"aaa",s:"1",a:"20",addr:"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA",email:"1111.222@aaa.com"},
{no:"2",n:"bbb",s:"2",a:"21",addr:"11111111111111111111111111111",email:"2222.222@aaa.com"},
{no:"3",n:"ccc",s:"1",a:"22",addr:"22222222222222222222222222222",email:"33333.222@aaa.com"},
{no:"4",n:"ddd",s:"2",a:"23",addr:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa",email:"44444.222@aaa.com"},
{no:"5",n:"eee",s:"2",a:"24",addr:"ccccccccccccccccccccccccccccc",email:"55555.222@aaa.com"}
];
$("#list19").jqGrid({
data:initdata,
datatype: "local",
colNames:['No','Name',"sex","age","addr","email"],
colModel:[
{name:'no',index:'no', width:50,sortable:false},
{name:'n',index:'n', width:80,sortable:false},
{name:'s',index:'s', width:50,sortable:false,hidden:true},
{name:'a',index:'a', width:30,sortable:false,hidden:true},
{name:'addr',index:'addr', width:300,sortable:false,hidden:true},
{name:'email',index:'email', width:100,sortable:false,hidden:true}
],
rowNum:30,
rowList:[10,20,30],
gridview:true,
autowidth:true,
pager: $('#pager19'),
sortname: 'No',
sortorder: "desc",
caption: "demo"
});
$(window).resize(function(){
jqgridresize();
});
});
var jqgridresize = function(){
var bodyw = $(document.body).width();
if(bodyw>600){
$("#list19").jqGrid('showCol',["s","a","addr","email"]);
}
else{
$("#list19").jqGrid('hideCol',["s","a","addr","email"]);
}
}
</script>
</head>
在resize浏览器的时候判断宽度,控制列的显示隐藏
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jqgridtest</title>
<link rel="stylesheet" type="text/css" media="screen" href="/js/jqgrid/themes/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/js/jqgrid/themes/redmond/jquery-ui-1.7.1.custom.css" />
<script src="/js/jqgrid/js/jquery.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var initdata = [
{no:"1",n:"aaa",s:"1",a:"20",addr:"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA",email:"1111.222@aaa.com"},
{no:"2",n:"bbb",s:"2",a:"21",addr:"11111111111111111111111111111",email:"2222.222@aaa.com"},
{no:"3",n:"ccc",s:"1",a:"22",addr:"22222222222222222222222222222",email:"33333.222@aaa.com"},
{no:"4",n:"ddd",s:"2",a:"23",addr:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa",email:"44444.222@aaa.com"},
{no:"5",n:"eee",s:"2",a:"24",addr:"ccccccccccccccccccccccccccccc",email:"55555.222@aaa.com"}
];
$("#list19").jqGrid({
data:initdata,
datatype: "local",
colNames:['No','Name',"sex","age","addr","email"],
colModel:[
{name:'no',index:'no', width:50,sortable:false},
{name:'n',index:'n', width:80,sortable:false},
{name:'s',index:'s', width:50,sortable:false,hidden:true},
{name:'a',index:'a', width:30,sortable:false,hidden:true},
{name:'addr',index:'addr', width:300,sortable:false,hidden:true},
{name:'email',index:'email', width:100,sortable:false,hidden:true}
],
rowNum:30,
rowList:[10,20,30],
gridview:true,
autowidth:true,
pager: $('#pager19'),
sortname: 'No',
sortorder: "desc",
caption: "demo"
});
$(window).resize(function(){
jqgridresize();
});
});
var jqgridresize = function(){
var bodyw = $(document.body).width();
if(bodyw>600){
$("#list19").jqGrid('showCol',["s","a","addr","email"]);
}
else{
$("#list19").jqGrid('hideCol',["s","a","addr","email"]);
}
}
</script>
</head>
在resize浏览器的时候判断宽度,控制列的显示隐藏
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询