日期:2014-05-16  浏览次数:20322 次

初学easyui的datagrid,获取json出现空数据
初学easyui,大部分代码都是复制粘贴,小错不要见怪
js代码

$(function() {
$('#Grid').datagrid( {
title : '人员显示',
iconCls : 'icon-save',
width : 1080,
height : 400,
pageSize:5,
    pageList:[5,10,15,20],
nowrap : true,
autoRowHeight : false,
striped : true,
collapsible : true,
url : '/FootBallClub/servlet/ShowPersonnel',
sortName : 'tpi_id',
sortOrder : 'asc',
remoteSort : false,
idField : 'tpi_id',
columns : [ [ {
field : 'ck',
checkbox : true
}, {
title : '人员编号',
field : 'tpi_id',
width : 140,
align : 'center',
sortable : true,
hidden : true
}, {
field : 'tpi_realName',
title : '姓名',
align : 'center',
width : 140
}, {
field : 'tpi_birth',
title : '生日日期',
align : 'center',
width : 140
}, {
field : 'tpi_phone',
title : '电话号码',
align : 'center',
width : 140
}, {
field : 'tpi_phone',
title : '学院',
align : 'center',
width : 140
}, {
field : 'tpi_sex',
title : '性别',
align : 'center',
width : 140
}, {
field : 'tpi_dormitory',
title : '宿舍号码',
align : 'center',
width : 140
}, {
field : 'opt',
title : '操作',
width : 140,
align : 'center',
formatter : function(value, rec) {
return '<span style="color:red">修改 删除</span>';
}
} ] ],
pagination : true,
rownumbers : true,
singleSelect : true,
checkOnSelect : true,
toolbar : [ {
id : 'btnadd',
text : '添加',
iconCls : 'icon-add',
handler : function() {
$('#btnsave').linkbutton('enable');
getSelected();
}
}, {
id : 'btncut',
text : '删除',
iconCls : 'icon-cut',
handler : function() {
$('#btnsave').linkbutton('enable');
alert('cut')
}
}, '-', {
id : 'btnsave',
text : '保存',
disabled : true,
iconCls : 'icon-save',
handler : function() {
$('#btnsave').linkbutton('disable');
alert('save')
}
} ]
});
function pagerFilter(data){
if (typeof data.length == 'number' && typeof data.splice == 'function'){
data = {
total: data.length,
rows: data
}
}
var dg = $('#Grid');
var opts = dg.datagrid('options');
var pager = dg.datagrid('getPager');
pager.pagination({
onSelectPage:function(pageNum, pageSize){
opts.pageNumber = pageNum;
opts.pageSize&nb