EXTJS动态获得数据的问题

calm_keep 2012-01-13 01:57:16
各位帮我看看以下代码哪里出错了
function loadGrid()
{
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'用户名',dataIndex:'username', width:200},
{header:'角色',dataIndex:'role', width:200}
]);
var data=[
['1','name1','desn1'],
['2','name1','desn1'],
['3','name1','desn1'],
['4','name1','desn1'],
['5','name1','desn1']
];
var ds=new Ext.data.Store({
remoteSort:true,
// proxy:new Ext.data.MemoryProxy(data),
//这里哪里出错了???
proxy:new Ext.data.DataProxy{
url : 'userAction_add.action',
method: 'post'
},
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'username'},
{name:'role'}
]),
successProperty: 'success'
});
ds.load({
params:{start : 0,
limit : 4}
});
var grid=new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
store: ds,
width:800,
height:600,
cm:cm,
bbar: new Ext.PagingToolbar({
pageSize: 4,
store: ds,
displayInfo: true,
beforePageText:"当前第",
afterPageText:"页,共{0}页",
lastText:"尾页",
nextText :"下一页",
prevText :"上一页",
firstText :"首页",
refreshText:"刷新页面",
displayMsg: '显示第{0} 条到{1} 条记录,一共{2} 条',
emptyMsg: "没有记录"
}),
tbar:[{text:"新增账号", handler:add_user},
{text:"修改账号", handler:edit_user},
{text:"删除账号", handler:del_user}]
});

return grid;
}


proxy:new Ext.data.DataProxy{
url : 'userAction_add.action',
method: 'post'
},
这里怎么出错了???
...全文
138 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
waybetter 2012-01-14
  • 打赏
  • 举报
回复
经过测试,这样改是没有问题的,红色部分括号一定不能少,若还是不行,你用ie测试,看看它提示什么错误
var ds=new Ext.data.Store({
remoteSort:true,
proxy:new Ext.data.HttpProxy({
url : 'common_commonSeach.action',
method: 'post'
}),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'username'},
{name:'role'}
]),
successProperty: 'success'
});
calm_keep 2012-01-14
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 loveliy520 的回复:]
userAction_add.action是放在根namespace中,还是有namespace限制,如果有namespace限制,则将命名空间也给加上
[/Quote]
没有任何限制,我放在别的别的url中没什么问题啊~~~
loveliy520 2012-01-13
  • 打赏
  • 举报
回复
userAction_add.action是放在根namespace中,还是有namespace限制,如果有namespace限制,则将命名空间也给加上
calm_keep 2012-01-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wanghao198612 的回复:]
1.确保你的userAction_add.action方法返回的是拼接正确的JSON字符串,特别不能是页面
2.userAction_add.action方法中success=true
3.totalProperty也要设置上去
[/Quote]
关键是他根本进不了后台的action,应该是在JS中的语法错误,不知道怎么改啊
calm_keep 2012-01-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 loveliy520 的回复:]
Java code

grid.store = new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'mails/receiveMail.action?folderType ='+config.folderType
}),
reader : n……
[/Quote]
关键是他根本进不了后台的action,应该是在JS中的语法错误,不知道怎么改啊
calm_keep 2012-01-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 waybetter 的回复:]
引用楼主 calm_keep 的回复:
proxy:new Ext.data.DataProxy{
url : 'userAction_add.action',
method: 'post'
},
这里怎么出错了???

//修改为
var ds=new Ext.data.Store({
remoteSort:true,
// proxy:new Ext.data.Memor……
[/Quote]
HttpProxy也不行啊~~~
loveliy520 2012-01-13
  • 打赏
  • 举报
回复

grid.store = new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
url : 'mails/receiveMail.action?folderType ='+config.folderType
}),
reader : new Ext.data.JsonReader( {
root : 'rows',
totalProperty : 'total'
}, recordType)
});
你需要将你的DataProxy修改为HttpProxy
waybetter 2012-01-13
  • 打赏
  • 举报
回复
[Quote=引用楼主 calm_keep 的回复:]
proxy:new Ext.data.DataProxy{
url : 'userAction_add.action',
method: 'post'
},
这里怎么出错了???
[/Quote]
//修改为
var ds=new Ext.data.Store({
remoteSort:true,
// proxy:new Ext.data.MemoryProxy(data),
//修改这里
proxy:new Ext.data.HttpProxy({
url : 'userAction_add.action',
method: 'post'
}),
wanghao198612 2012-01-13
  • 打赏
  • 举报
回复
1.确保你的userAction_add.action方法返回的是拼接正确的JSON字符串,特别不能是页面
2.userAction_add.action方法中success=true
3.totalProperty也要设置上去
waybetter 2012-01-13
  • 打赏
  • 举报
回复

var ds=new Ext.data.Store({
remoteSort:true,
// proxy:new Ext.data.MemoryProxy(data),
//这里哪里出错了???
proxy:new Ext.data.DataProxy{//DataProxy是一个纯虚类,用于生成Ext.data.Record对象
url : 'userAction_add.action',
method: 'post'
},

//修改为
var ds=new Ext.data.Store({
remoteSort:true,
// proxy:new Ext.data.MemoryProxy(data),
//修改这里
proxy:new Ext.data.HttpProxy({
url : 'userAction_add.action',
method: 'post'
}),

81,092

社区成员

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

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