请问jqGrid怎么动态的改变里边的列
http://zhidao.baidu.com/question/421647527.html?quesup2&oldq=1悬赏分在下边的那个地址里,好心人帮帮忙,急用...
http://zhidao.baidu.com/question/421647527.html?quesup2&oldq=1
悬赏分在下边的那个地址里,好心人帮帮忙,急用 展开
悬赏分在下边的那个地址里,好心人帮帮忙,急用 展开
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>
<body>
<table id="list19" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager19" class="scroll" style="text-align:center;"></div>
</body>
</html>
<!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>
<body>
<table id="list19" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager19" class="scroll" style="text-align:center;"></div>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询