如何利用jqGrid表格方法重新设置caption属性值

 我来答
撩汉那一抹浅笑
2017-09-03 · TA获得超过617个赞
知道大有可为答主
回答量:1224
采纳率:83%
帮助的人:1171万
展开全部
1、问题背景
(1)jqGrid生成表格带有标题,固定不变的
(2)表格标题随着年份进行变化
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>如何设置表格caption值</title>
<link rel="stylesheet" href="../css/ui.jqgrid-bootstrap-ui.css" />
<link rel="stylesheet" href="../css/ui.jqgrid-bootstrap.css" />
<link rel="stylesheet" href="../css/ui.jqgrid.css" />
<script src="../js/jquery-1.11.0.min.js"></script>
<script src="../js/jquery.jqGrid.min.js"></script>
<script src="../js/i18n/grid.locale-cn.js"></script>
<script>
$(function(){
var date = new Date();
var year = date.getFullYear();

var student = [
{id:'001',name:'zhangsan1',sex:'m',age:23},
{id:'002',name:'zhangsan2',sex:'w',age:20},
{id:'003',name:'zhangsan3',sex:'m',age:22},
{id:'004',name:'zhangsan4',sex:'w',age:21},
{id:'005',name:'zhangsan5',sex:'m',age:19},
{id:'006',name:'zhangsan6',sex:'w',age:18},
{id:'007',name:'zhangsan7',sex:'m',age:24},
{id:'008',name:'zhangsan8',sex:'w',age:20},
{id:'009',name:'zhangsan9',sex:'m',age:25},
{id:'010',name:'zhangsan10',sex:'w',age:23}
];
$("#title-grid-table").jqGrid({
data:student,
datatype:'local',
caption:'学生信息表',
height:'auto',
rowNum: 30,
rowList: [10,20,30],
colNames:['编号','姓名','性别','年龄'],
colModel:[
{name:'id',index:'id', width:300, sorttype:"int"},
{name:'name',index:'name', width:300,editable:true},
{name:'sex',index:'sex',width:300},
{name:'age',index:'age',width:300}
],
pager: "#title-grid-pager",
viewrecords: true,
sortname: 'name',
loadComplete:function(){
$(this).jqGrid("setCaption",year+"年毕业学生信息表");
}
});
});
</script>
</head>
<body>
<div>
<table id="title-grid-table"></table>
<table id="title-grid-pager"></table>
</div>
</body>
</html>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式