PDA

View Full Version : convert function not completing?



sway
15 Sep 2010, 12:09 AM
I have a Ext.data.Store that loads data from a remote server and uses a Ext.data.ArrayReader with a converter for one of the fields, like:


var genericFeaturesStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'getRecords.do'}),

reader: new Ext.data.ArrayReader({}, [

{ name: 'title' },
{ name: 'records', convert : convertRecords}
]),

...

});

The problem I am having is that the convertRecords() seems to begin execution but not complete, although the application is not stuck but appears as if convertRecords() has returned. My first question - is the convert function associated with ArrayReader records asynchronous, causing the appearance of a functional application even though the convert function has not returned? (I have done a google search and can't find anything) Second question - how can I debug why my convert function is not returning? Breakpoints don't seem to help, maybe because it is executing asynchronously...?

laurentParis
15 Sep 2010, 12:33 AM
Can you show us convertRecords method ?
(please, use tag code)

sway
15 Sep 2010, 3:43 PM
<code>
var convertRecords = function(v, record) {
alert("begin convertRecords");
for (var i = 0; i < v.length; i++) {
v[i] = new Record(
v[i].title,
v[i].description,
v[i].contactOrg,
v[i].serviceType,
);
}

return v;
};
</code>

sway
15 Sep 2010, 4:03 PM
var convertRecords = function(v, record) {
for (var i = 0; i < v.length; i++) {
v[i] = new Record(
v[i].title,
v[i].description,
v[i].serviceType,
v[i].serviceURLs,
v[i].keywords);
}
return v;
};

sway
15 Sep 2010, 6:22 PM
Solved my own problem...


genericFeaturesStore.on({
'load': {
fn: function(store, records, options) {
alert("load");
},
scope: this
},
'loadexception': {
fn: function(obj, options, response, e) {
alert("error: "+e);
},
scope: this
}
});

Allowed me to see that it was throwing an error because it couldn't find the serviceType for one of the many records.

sway
15 Sep 2010, 6:22 PM
Solved my own problem...


genericFeaturesStore.on({
'load': {
fn: function(store, records, options) {
alert("load");
},
scope: this
},
'loadexception': {
fn: function(obj, options, response, e) {
alert("error: "+e);
},
scope: this
}
});Allowed me to see that it was throwing an error because it couldn't find the serviceType for one of the many records.

Animal
15 Sep 2010, 9:12 PM
Bizarre converter which returns an object as a field value!