extjs grid 从后台取数据问题,来者有分

possibleonline 2009-04-07 06:37:15

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 : "num", root : "arr",id : "number"},recordType);

var proxy=new Ext.data.HttpProxy({url : 'http://127.0.0.1:8080/Extjs03/personInfoGridLoad.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>编号</center>',dataIndex:'number',width:100},
{header:'<center>名称</center>',dataIndex:'name',width:200},
{header:'<center>作者</center>',dataIndex:'author',width:80},
{header:'<center>出版社</center>',dataIndex:'press',width:200},
{header:'<center>价格</center>',dataIndex:'price',width:50},
{header:'<center>语种</center>',dataIndex:'language',width:70},
{header:'<center>是否借出</center>',dataIndex:'lend',width:60}
]
});


var libraryInfoGrid = new Ext.grid.GridPanel({
title:'图书信息',
store: ds,
cm: cm,
sm:sm,
renderTo:Ext.getBody(),
width:800,
height:400,
tools:[{id:"save"},{id:"help",handler:function(){Ext.MessageBox.alert("工具栏按钮","工具栏上的关闭按钮时间被激发了")}}],
tbar:[{
text:'新增图书',
tooltip:'新增图书信息',
iconCls:'add'
}, '-', {
text:'修改',
tooltip:'修改图书信息',
iconCls:'option'
},'-',{
text:'删除',
tooltip:'删除图书信息',
iconCls:'remove'
}],
region:'center',
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});

});

其中访问http://127.0.0.1:8080/Extjs03/personInfoGridLoad.jsp将得到<br/>
{"arr":[{"author":"张孝详","language":"中文","lend":"否","name":"数据库","number":"10","press":"武汉大学出版社","price":"23.00"},{"author":"Scott Bee","language":"英文","lend":"是","name":"thinking in java","number":"20","press":"abc","price":"108"}],"num":2} <br/>
为什么显示不了数据呢?



...全文
511 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
我是初学者 能不能给我一个 extjs连接数据库的代码
mutouyujing 2009-05-26
  • 打赏
  • 举报
回复
’http://127.0.0.1:8080/Extjs03/personInfoGridLoad.jsp‘这个里面的代码该怎么写啊?
mutouyujing 2009-05-26
  • 打赏
  • 举报
回复
我是初学者,研究Extjs从后台读取数据绑定到Extjs的grid中,能不能给个具体实例啊,谢了啊
kyokk2005 2009-04-08
  • 打赏
  • 举报
回复
json="{arr:[{author:'张1221孝详',language:'中文',lend:'否',name:'数据库',number:'10',press:'武汉大学出版社',price:'23.00'},{author:'Scott Bee',language:'英文',lend:'是',name:'thinking in java',number:'20',press:'abc',price:'108'}],num:3}";
response.getWriter().print(json);
胡须棉花糖 2009-04-07
  • 打赏
  • 举报
回复
json中加上的{success:true,"arr":[{"author"。。。。
Miracle1216 2009-04-07
  • 打赏
  • 举报
回复
顶。JSP忘了啊。你最好把jsp中的关键代码也贴上了。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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