ext用json读数据。不显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Grid.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="ext/resources/css/ext-all.css" type="text/css"></link>
<script type="text/javascript" src="ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>
</head>
<body>
<div id="divGrid" style="width:800px;height:300px;">
</div>
</body>
<script type="text/javascript">
var sm = new Ext.grid.CheckboxSelectionModel();
var grid ;
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
sm,
{header:'编号',dataIndex:'id'},
{header:'姓名',dataIndex:'name'},
{header:'年龄',dataIndex:'age'},
{header:'生日',dataIndex:'birth'},
{header:'地址',dataIndex:'addr'},
{header:'电话',dataIndex:'tel'}
]);
var Userrecord = new Ext.data.Record([
{name:'id',type:'int'},
{name:'name',type:'String'},
{name:'age',type:'int'},
{name:'birth',type:'String'},
{name:'addr',type:'String'},
{name:'tel',type:'String'}
]);
/* var data=[
['001','张三','25','1/1 12:00am','湖北','152723798238'],
['002','李四','22','1990-8-1','湖南','152768798438'],
['003','王五','23','1990-8-3','河南','152788798792'],
['004','赵六','24','1990-8-2','四川','152758798334']
];*/
var store = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:'UserServlet'
}),
reader:new Ext.data.JsonReader(
{totalProperty:'totalProperty',root:'root'},
[
{name:'id'},
{name:'name'},
{name:'age'},
{name:'birth'},
{name:'addr'},
{name:'tel'}
]
)
/* proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'age'},
{name:'birth'},
{name:'addr'},
{name:'tel'}
])*/
});
store.load({
params:{start:0,limit:4}
});
/* grid= new Ext.grid.GridPanel({
viewConfig:{forceFit:true},
store:store,
height:350,
width:700,
sm:sm,
cm:cm
});*/
grid = new Ext.grid.EditorGridPanel({
renderTo:'divGrid',
viewConfig:{forceFit:true},
store:store,
height:350,
width:700,
loadMask:true,
sm:sm,
cm:cm
});
//grid.render("divGrid");
</script>
</html>
------解决方案--------------------
碰到这类问题基本上就去看几个地方, 首先看看后台有没有传出数据, 然后看看传出的 json 数据格式是不是正确
------解决方案--------------------