我正在尝试将此阅读器从 Ext 3 转换为 Ext 4。JavaScript 正在引发异常。我正确转换了吗?
JavaScript 异常:
Uncaught TypeError: Cannot read property 'prototype' of undefined
代码(转换后的行注释):
Ext.onReady(function () {
Ext.Direct.addProvider(Ext.app.REMOTING_API);
//var reader = new Ext.data.JsonReader({ // convert from ext 3 to ext 4
var reader = Ext.create('Ext.data.JsonReader', {
totalProperty: 'results',
successProperty: 'success',
idProperty: 'id',
root: 'data'
}, [{
name: 'id'
}, {
name: 'email',
allowBlank: false
}, {
name: 'first',
allowBlank: false
}, {
name: 'last',
allowBlank: false
}]
);
//var writer = new Ext.data.JsonWriter({ // convert from ext 3 to ext 4
var writer = Ext.create('Ext.data.JsonWriter', {
returnJson: false,
writeAllFields: true
});
//var store = new Ext.data.DirectStore({ // convert from ext 3 to ext 4
var store = Ext.create('Ext.data.DirectStore', {
api: {
read: CRUDSampleMethods2.read,
create: CRUDSampleMethods2.create,
update: CRUDSampleMethods2.update,
destroy: CRUDSampleMethods2.destroy
},
reader: reader,
baseParams: {
dummy: 'blubb'
},
writer: writer,
paramsAsHash: true,
batchSave: false,
batch: false,
prettyUrls: false,
remoteSort: true,
listeners: {
load: function (result) { },
loadexception: function () {
},
scope: this
}
});
// ... code continues
编辑:
修复了这个:
var reader = Ext.create('Ext.data.JsonReader', {
totalProperty: 'results',
successProperty: 'success',
idProperty: 'id',
root: 'data'
});
并添加模型:
var store = Ext.create('Ext.data.DirectStore', {
model: 'User',
api: {