myloveisnt
2013-04-11 00:02
浏览 807
已采纳

Ext.data.Store 后台加载数据,加载不进去

//extjs版本4.0.7 代码如下:

Ext.define("Role",{

extend:"Ext.data.Model",

fields:[

 {name:'num',type:'string',min:1,max:8},

 {name:'name',type:'string',min:1,max:50},

 {name:'valid',type:'int',min:1,max:1},

 {name:'bz',type:'string'}

]

});

var arrayStore = new Ext.data.Store({

proxy :new Ext.data.HttpProxy({  

 url : '<%=basePath%>role.do?action=list'     

}),

reader : new Ext.data.JsonReader({

 model: 'Role'

})  

});

arrayStore.load();

//返回的数据

[

{"bz":"5","name":"角色5","num":"00000023","valid":1},

{"bz":"4","name":"角色4","num":"00000021","valid":1},

{"bz":"2","name":"角色3","num":"00000003","valid":1},

{"bz":"1","name":"角色2","num":"00000002","valid":1},

{"bz":"1","name":"角色1","num":"00000001","valid":1}

]
浏览器报错:
火狐 : this.model is undefined
IE : prototye is null

另外一种数据格式我也试过了:

[

['00000023','角色5',1,'5'],

['00000021','角色4',1,'4'],

['00000003','角色3',1,'2'],

['00000002','角色2',1,'1'],

['00000001','角色1',1,'1']

]

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • jinbingchuan 2013-04-11 09:20
    已采纳

    给你一个例子吧

    Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [
    {name: 'firstName', type: 'string'},
    {name: 'lastName', type: 'string'},
    {name: 'age', type: 'int'},
    {name: 'eyeColor', type: 'string'}
    ]
    });

    var myStore = Ext.create('Ext.data.Store', {
    model: 'User',
    proxy: {
    type: 'ajax',
    url : '/users.json',
    reader: {
    type: 'json',
    root: 'users'
    }
    },
    autoLoad: true
    });

    点赞 打赏 评论
  • FangXingXing007 2013-04-11 09:08

    reader好像需要定义到proxy里面
    4.0.7的官方API里面,Ext.data.Store没有reader这个配置项

    点赞 打赏 评论

相关推荐 更多相似问题