EXT grid那不到后台数据??

liyunxin 2009-11-10 01:20:11
js代码:
Ext.onReady( function() {
var recordType = new Ext.data.Record.create( [ {
name :"number",
type :"string"
},

{
name :"name",
type :"string"
},

{
name :"author",
type :"string"
},

{
name :"press",
type :"string"
},

{
name :"price",
type :"string"
},

{
name :"language",
type :"string"
},

{
name :"lend",
type :"string"
}

]);

var reader = new Ext.data.JsonReader(

{
totalProperty :"results",
root :"rows",
id :"number"
}, recordType);

var proxy = new Ext.data.HttpProxy( {
url :'gridLoad.jsp'
});

var ds = new Ext.data.Store( {
proxy :proxy,
reader :reader
});

ds.load(); // 加载数据,必须的。

var sm = new Ext.grid.CheckboxSelectionModel();

var cm = new Ext.grid.ColumnModel( {

defaultSortable :true,

columns : [ sm, {
header :'<center>number</center>',
dataIndex :'number',
width :100
}, {
header :'<center>name</center>',
dataIndex :'name',
width :200
}, {
header :'<center>author</center>',
dataIndex :'author',
width :80
}, {
header :'<center>press</center>',
dataIndex :'press',
width :200
}, {
header :'<center>price</center>',
dataIndex :'price',
width :50
}, {
header :'<center>language</center>',
dataIndex :'language',
width :70
}, {
header :'<center>lend</center>',
dataIndex :'lend',
width :60
} ]
});

var libraryInfoGrid = new Ext.grid.GridPanel( {
title :'tushuxinxi',
store :ds,
cm :cm,
sm :sm,
width :800,
height :100,

region :'center',

});
libraryInfoGrid.render('grid-example');

直接访问 gridLoad.jsp 能拿到结果:
{"arr":[{"author":"李四","language":"中文","lend":"是","name":"JAVA编程思想","number":"0001","press":"机械工业出版社","price":"100"},{"author":"qqq","language":"qqq","lend":"qqq","name":"qqq","number":"001","press":"qqq","price":"qqq"}],"num":2}

谁帮忙下??
...全文
60 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liyunxin 2009-11-10
  • 打赏
  • 举报
回复
谢了,刚开始学EXT.能不能推荐几个用ext做的开源项目啊,我学习下??
sohighthesky 2009-11-10
  • 打赏
  • 举报
回复
totalProperty :"results",
改为totalProperty :"num",
这些属性的名字,是根据你服务器的的json来的
sohighthesky 2009-11-10
  • 打赏
  • 举报
回复

JsonReader中

root :"rows",
改为root:"arr"

52,787

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧