PDA

View Full Version : one ajax loading several stores. [Solved]



michaelc
3 Sep 2010, 3:15 PM
I did this before, but I seem to be having Friday afternoon brain farts.

ok I have one backend call that I want to load three stores, so the store does not have a proxy.
So anyone see what I am doing wrong, or a pointer to example.
I am no longer at the place where I did this same thing so I don't have that code available.

here is the store


var regionStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
root:'regionListDataObj'
},
[
{name: 'Region_Description'},
{name: 'region_id'}
]),
listeners: {
load: function(store, records, options){
alert('Records loaded: ' + records.length);
},
loadexception: function(proxy, options, response, e){
alert('Error occurred: ' + e);
}
}

});
The Json data looks like this


{
"success": true,
"regionListDataObj": [
{
"region_id": "1",
"Region_Description": "KP Northwest"
},
{
"region_id": "9",
"Region_Description": "KP Program Office"
}
],
"positionListDataObj": [
{
"position_id": "1",
"position_Description": "Biostatistician"
},
{
"position_id": "14",
"position_Description": "VDW Consultant"
}
],
"specialtiesListDataObj": [
{
"AREA_INTEREST_DESCRIPTION": "Clinical Population",
"GROUP_DESCRIPTION": "Aging\/ Geriatrics",
"SPECIALTY_DESCRIPTION": "Aging\/ Geriatrics",
"specialty_ID": "28",
"SPECIALTY_VALUE": null
}, {
"AREA_INTEREST_DESCRIPTION": "Study Design",
"GROUP_DESCRIPTION": "Synthetic studies",
"SPECIALTY_DESCRIPTION": "Systematic review studies",
"specialty_ID": "26",
"SPECIALTY_VALUE": null
}
]
}
with a basic Ajax call


Ext.Ajax.request( {
url : '/services/ProfileSearch.php',
success : function(result, request) {
var jsonResp = Ext.util.JSON.decode(result.responseText); // pull response back and process.
if (jsonResp.success){
regionStore.load(jsonResp.regionListDataObj);
}else{
Util.showError(
jsonResp.messageText,
'Critical Error'
)
}
},
failure : function() {
Ext.MessageBox.alert('Error', 'Backend service failure');

},
params : {

'action' : 'getValues'
}
});
Any help would be very gladly accepted.

michaelc
4 Sep 2010, 7:31 AM
I see the errors of my ways.
loaddata vs. load.
that fixed the issue, same issue I had in Dec 09 http://www.sencha.com/forum/showthread.php?87374-Solved-Load-a-grid-from-JSON-simple.

michaelc
4 Sep 2010, 7:33 AM
Need to use loaddata vs load

same answer as in Devember 09.
now if I add a link to an edited note will it be posted
http://www.sencha.com/forum/showthread.php?87374-Solved-Load-a-grid-from-JSON-simple.

Yaaa kewl there is my answer