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:'Re',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, Re=null, AutoID=1, Tel=123456}]但是在js页面中的CompanyStore没有记录 

解决方案 »

  1.   

     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, Re=null, AutoID=1, Tel=123456}]]
    这样吗?
      

  2.   

    他的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, Re=null, AutoID=1, Tel=123456}]}
      

  3.   

    action 如下:public class CompanyListAction extends ActionSupport {
        public String execute() throws Exception {
            String strsql="select AutoID,CompanyNO,CompanyName,Tel,Fax,Address,AddressEng,\n"+
                    "Postcode,Re,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;
    }
    }
      

  4.   

    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'}
           ]
    });
      

  5.   


    'companylist':[
            { 'name': 'Lisa',  "email":"[email protected]",  "phone":"555-111-1224"  },
            { 'name': 'Bart',  "email":"[email protected]",  "phone":"555-222-1234" },
            { 'name': 'Homer', "email":"[email protected]",  "phone":"555-222-1244"  },
            { 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254"  }
        ]///参照此格式返回数据
      

  6.   

    public class CompanyListAction extends ActionSupport {
        public String execute() throws Exception {
            String companylist="[{ 'AutoID': 1,'CompanyNO':'GC','CompanyName':'GC','Tel':'123'}]";
         return this.SUCCESS;
    }
    }
    我换成上面的数据源 还是加载不了
      

  7.   

    {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, Re=null, AutoID=1, Tel=123456}]}最外面是大括号,不是方括号!!!
      

  8.   

    不好意思 第一次使用 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,Re,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;
    }
    }
    增加红色字体