PDA

View Full Version : problem with Ext.data.reader in Ext.application



sergeyvo
18 Jan 2012, 7:37 PM
Env


var Env = Ext.ModelManager.getModel('ARM.model.Environment');

it works


Ext.onReady(function(){
.............
Env.load(1201, {
success: function(record, operation) {
// record is define as Data.model record
}
});
});


it not works :-(


Ext.application({
.............
launch: function() {
Env.load(1201, {
success: function(record, operation) {
// record is not define :-(
// operation is define and contains the true JSON data in response
}
});
});
});

sergeyvo
18 Jan 2012, 10:07 PM
sorry, reader is work correctly
i create custom reader for test, reader its work


Ext.define('EnvReader', {
extend : 'Ext.data.reader.Json',
alias: 'reader.EnvReader',
read: function(response) {
var respJSON = Ext.JSON.decode(response.responseText)
data = respJSON;
return this.callParent([data]);
}
});


operation.ResultSet.records is empty on Ext.application :-(
operation.ResultSet.records is not empty if not use Ext.application
please help me!!!!

sergeyvo
19 Jan 2012, 7:57 PM
other example
i'm use custom proxy and operation for data reading,
if i do not define id: 1201, I get a response containing all the records in ResultSet,
it work with use Ext.Application and without Ext.Application.

if i do define id: 1201, I get a response containing all the record in ResultSet
it works without Ext.Application (ResultSet containing 1 record )
and NOT WORKS (ResultSet containing 0 record) if you use Ext.Application.



var operation = new Ext.data.Operation({
id: 1201,
action: 'read'
});
var EnvProxy = new Ext.data.proxy.Rest({
url: 'data/environment',
reader: { type: 'EnvReader' }
});
EnvProxy.read(operation, function(op) {
console.log(op.getResultSet());
});