PDA

View Full Version : Ext.data.Store callback problem



kurtschrauwen
9 Nov 2011, 6:30 AM
Hey Everyone,

I have a problem with Ext.data.Store callback. I'm staring at it for a few days now and I don't see what is wrong with my code.
I have made a function that retrieves a record from a table out of an MySQL database. When I call the PHP function to retrieve the data and return the JSON it gives the wright data.
This I can check because sometimes my code works and sometimes it doesn't.
When I debug I can see that the callback sometimes fires and sometimes it don't.

Can some give me a clue why this happens ?



function getSystemConnection(arg_userID){

var li_ID = 0;
var ls_userName = '';
var li_joomlaUserID = 0;
var li_extjsLedenID = 0;
var li_extjsClubID = 0;

var ds_systemConnection = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields:['ID','userName','joomlaUserID','extjsLedenID','extjsClubID'],
root:'rows'
}),
baseParams: { joomlaUserID:arg_userID },
proxy: new Ext.data.HttpProxy({
url:'php/user_system_connection_GET.php' (http://www.sencha.com/forum/'php/user_system_connection_GET.php'),
method:'POST'
})
});

ds_systemConnection.load({
callback: function(r,options,success) {
if(success == true) {
if(r.length == 0) {
// OK
}else{
li_ID = ds_systemConnection.getAt(0).data.ID;
ls_userName = ds_systemConnection.getAt(0).data.userName;
li_joomlaUserID = ds_systemConnection.getAt(0).data.joomlaUserID;
li_extjsLedenID = ds_systemConnection.getAt(0).data.extjsLedenID;
li_extjsClubID = ds_systemConnection.getAt(0).data.extjsClubID;
}
}else{
Ext.MessageBox.alert('Info','No System Connection found');
}
}
});

return li_extjsLedenID;
}


Thanks,
Kurt

mitchellsimoens
18 Nov 2011, 12:13 PM
It should always fire... the only thing that could keep it from firing is an if statement that simply checks to see if the callback config is specified in the options. Have you tried using the load event instead of the callback?