PDA

View Full Version : Help with Ext.data.Connection callback



Zoze
14 Aug 2009, 6:36 AM
Hi all,

I have a grid and I invoke the 'datachanged' event when I sort (locally) a column like this:

this.Storage = function() {
this.store = new Ext.data.JsonStore({
root: 'rows',
fields: this.fields,
listeners: {
datachanged: this.reorder
}
});
}

where reorder() makes an Ext.data.Connection request for each store entry through getTemplate() function:

this.reorder = function (ds) {
for (var i = 0; i < ds.getCount(); i++) {
getTemplate(ds.getAt(i).get('id'));
}
}

Finally, getTemplate():

function getTemplate (id){
var uri = path/id;
var conn = new Ext.data.Connection();
conn.request({
url: uri,
method: 'GET',
success: function(responseObject) {
myVar = responseObject.responseText;
},
callback: function() {
$("#myDiv").val($("#myDiv").val() + id + ". " + myVal + "\r\n");
}
});
}

where myVal is global variable. As you notice I want to append the text area content with the value I get on success from server. But I need it to be done in proper order (after local sorting) so I need to 'block' somehow the getTemplate(). What am I doing wrong ? It seems to be printed in random row... Please help

Animal
14 Aug 2009, 7:26 AM
Did you read the bold Important note in the description of the request method?