日期:2014-05-17  浏览次数:20860 次

关于flexigrid的问题,谁找到了小妹有奖励!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Flexigrid</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" type="text/css" href="css/flexigrid/flexigrid.css">
<script type="text/javascript" src="lib/jquery/jquery-1.7.1.js"></script>
<script type="text/javascript" src="flexigrid.js"></script>

<style>

.flexigrid div.fbutton .add
{
background: url(css/images/add.png) no-repeat center left;
}

.flexigrid div.fbutton .delete
{
background: url(css/images/close.png) no-repeat center left;
}

</style>

</head>
<script type="text/javascript">
$.ajax({
type:"post",
url:"servlet/StudentListServlet",
success:function(data){
if(data){
for(var i =0;i<data.length;i++){
alert(data[i].NAME);//有值
alert(data[i].EMAIL);//有值

}
}
$("#flex1").flexigrid
(
{
url: 'servlet/StudentListServlet',
dataType: 'json',
colModel : [
{display:'序号',name:'ID',width:40,sortable:true,align:'center'},
{display:'名称',name:'NAME',width:40,sortable:true,align:'center'},
{display:'年龄',name:'AGE',width:40,sortable:true,align:'center'},
{display:'电话',name:'PHONE',width:40,sortable:true,align:'center'},
{display:'邮件',name:'EMAIL',width:40,sortable:true,align:'center'}
],
buttons : [
{name:'ADD',bclass:'add',onpress:test},
{name:'DELETE',bclass:'delete',onpress:test},
{separatpr:true}
],
searchitems : [
{display:'序号',name:'ID'},
{display:'名称',name:'NAME',isdefault:true}
],
usepager: true,
title: '最新职位',
useRp: true,
rp: 15,
showTableToggleBtn: true,
width: 700,
height: 200
}
);
function test(com,grid)
{
if (com=='Delete')
{
confirm('Delete ' + $('.trSelected',grid).length + ' items?')
}
else if (com=='Add')
{
alert('Add New Item');
}
}

}

});
</script>
<body>



<table id="flex1" style=""></table>



</body>
</html>


我用ajax 调用servlet的时候是没问题的,但是用flexigrid表格中却没有数据,我很费解!
这是json 结果[{"PHONE":"123","NAME":"name1","AGE":1,"ID":"1","EMAIL":"email1"}]
QQ 1766323372 在线等!
------解决方案--------------------
返回的数据应该是这样的
{"rows":[{"id":121,"cell":["123","name1",1,"1",email1]}]}