extjs4.0 给grid加载数据 问题

asp_c 2011-09-16 01:33:33

Ext.define('CompanyModel', {
extend:'Ext.data.Model',
fields:[
{name:'AutoID',type:'int'},
{name:'CompanyNO',type:'string'},
{name:'CompanyName',type:'string'},
{name:'Tel',type:'string'},
{name:'Address',type:'string'},
{name:'AddressEng',type:'string'},
{name:'Postcode',type:'string'},
{name:'Remark',type:'string'},
{name:'Creator',type:'string'},
{name:'CreatedTime',type:'string'},
{name:'DeletedBy',type:'string'},
{name:'DeletedTime',type:'string'},
{name:'Deleted',type:'boolean'}
]
});

var CompanyStore=Ext.create('Ext.data.Store',{
model: 'CompanyModel',
proxy: {
type: 'ajax',
url: 'listCompany.action',
reader: {
type: 'json',
root: 'companylist'
}
},
autoLoad: false
});
CompanyStore.load();



listCompany.action 可以执行

companylist为:
[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address=上海, DeletedTime=null, AddressEng=shanghai, Remark=null, AutoID=1, Tel=123456}]

但是在js页面中的CompanyStore没有记录
...全文
303 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
asp_c 2011-09-18
  • 打赏
  • 举报
回复
不好意思 第一次使用 structs 问题自己试出来了

public class CompanyListAction extends ActionSupport {


private List<Company> companylist=new ArrayList();

public List<Company> getCompanylist() {
return companylist;
}


public String execute() throws Exception {
String strsql="select AutoID,CompanyNO,CompanyName,Tel,Fax,Address,AddressEng,\n"+
"Postcode,Remark,Creator,CreatedTime,DeletedBy,DeletedTime,Deleted from HR_Company where Deleted=0";
companylist=(List<Company>)getwlcspService().findBySQL(strsql);
System.out.print("companylist------------"+companylist);

return this.SUCCESS;
}
}


增加红色字体
asp_c 2011-09-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 cnsjd 的回复:]
{companylist:[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address=上海, DeletedTime=null, AddressEng=shangh……
[/Quote]

还是 不行 我郁闷死了
醒道 2011-09-17
  • 打赏
  • 举报
回复
{companylist:[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address=上海, DeletedTime=null, AddressEng=shanghai, Remark=null, AutoID=1, Tel=123456}]}

最外面是大括号,不是方括号!!!
asp_c 2011-09-16
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 c3716317 的回复:]
把返回值里的=号换成:试试
[/Quote]


public class CompanyListAction extends ActionSupport {
public String execute() throws Exception {
String companylist="[{ 'AutoID': 1,'CompanyNO':'GC','CompanyName':'GC','Tel':'123'}]";
return this.SUCCESS;
}
}


我换成上面的数据源 还是加载不了
大哥-你真棒 2011-09-16
  • 打赏
  • 举报
回复

'companylist':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]///参照此格式返回数据
大哥-你真棒 2011-09-16
  • 打赏
  • 举报
回复
把返回值里的=号换成:试试
asp_c 2011-09-16
  • 打赏
  • 举报
回复
grid代码如下:
var companyGridPanel=Ext.create('Ext.grid.Panel', {
id:'grid_companygridpanel_id',
name:'grid_companygridpanel_name',
loadMask: true,
columnLines: true,
disableSelection: false,
renderTo:'CompanyList',
store:CompanyStore,
columns: [
{header:'AutoID',dataIndex : 'AutoID'},
{header:'CompanyNO',dataIndex : 'CompanyNO'},
{header:'CompanyName',dataIndex:'CompanyName'},
{header:'Tel',dataIndex:'Tel'}
]
});
asp_c 2011-09-16
  • 打赏
  • 举报
回复
action 如下:

public class CompanyListAction extends ActionSupport {
public String execute() throws Exception {
String strsql="select AutoID,CompanyNO,CompanyName,Tel,Fax,Address,AddressEng,\n"+
"Postcode,Remark,Creator,CreatedTime,DeletedBy,DeletedTime,Deleted from HR_Company where Deleted=0";
List<Company> companylist=(List<Company>)getwlcspService().findBySQL(strsql);
System.out.print("companylist------------"+companylist);
return this.SUCCESS;
}
}
asp_c 2011-09-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 guowangsheng2011 的回复:]
root: 'companylist'

你的action得回的结果是
[companylist:[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address……
[/Quote]

是的
醒道 2011-09-16
  • 打赏
  • 举报
回复
他的ACTION结果应该是
{companylist:[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address=上海, DeletedTime=null, AddressEng=shanghai, Remark=null, AutoID=1, Tel=123456}]}
一品 2011-09-16
  • 打赏
  • 举报
回复
root: 'companylist'

你的action得回的结果是
[companylist:[{Deleted=false, CreatedTime=2011-09-15 08:30:23.0, Creator=jet, Fax=123456, DeletedBy=null, CompanyNO=AA, CompanyName=AA, Postcode=123466, Address=上海, DeletedTime=null, AddressEng=shanghai, Remark=null, AutoID=1, Tel=123456}]]
这样吗?
醒道 2011-09-16
  • 打赏
  • 举报
回复
你的GRID 怎么写的
asp_c 2011-09-16
  • 打赏
  • 举报
回复
自己顶

87,990

社区成员

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

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