djfloetic
20 Jul 2007, 10:39 AM
I'm trying to basically acquire data from the database via a JSON request. There are multiple stores involved and have callbacks setup to call another callback once the data has been requested.
The first store loads and displays data on a grid fine but the 2nd store: 'statsDS' doensn't get to load properly for some reason, and maybe I'm just confused with the scoping.
This is the first store that gets loaded, notice that Callback calls 'generateStatsDS()' once it is done.
// trigger the data store load
ds.load({params:{func: 'viewAllApprovalRequired', start:0, limit:30, userRole: 'security'}},
{callback:generateStatsDS()});
ds.baseParams.func = "viewAllApprovalRequired";
This is the call back function that gets called once it is finished with previous data load.
var statsDS;
function generateStatsDS() {
// create the Data Store
// App Control Combo Data Store
statsDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: './includes/database/dbmanager.php'
}),
// create reader that reads the records
reader: new Ext.data.JsonReader({},['numMembers', 'numClasses'])
});
statsDS.baseParams.func = "getStats";
statsDS.load({params: {func: 'getStats'}}, {callback:renderStats()}, {scope:this});
}
//* r : Ext.data.Record[]
//* options: Options object from the load call
//* success: Boolean success indicator
Also below, it makes a callback to the 'renderStats()' function once this load is complete.
function renderStats(r, options, success) {
var numMembers = statsDS.getAt(0).data.numMembers;
var numClasses = statsDS.getAt(0).data.numClasses;
// Render statistics
Ext.get('numMembers').dom.innerHTML = numMembers;
Ext.get('numClasses').dom.innerHTML = numClasses;
}
However, my problem is that from a scoping standpoint, parameters: r, options, success have no value and aren't defined as stated in the API docs: http://extjs.com/deploy/ext/docs/output/Ext.data.Store.html#load
Is the Scoping correct or am I missing something. While stepping through with firebug, it is not defined.
Thoughts? Ideas?
The first store loads and displays data on a grid fine but the 2nd store: 'statsDS' doensn't get to load properly for some reason, and maybe I'm just confused with the scoping.
This is the first store that gets loaded, notice that Callback calls 'generateStatsDS()' once it is done.
// trigger the data store load
ds.load({params:{func: 'viewAllApprovalRequired', start:0, limit:30, userRole: 'security'}},
{callback:generateStatsDS()});
ds.baseParams.func = "viewAllApprovalRequired";
This is the call back function that gets called once it is finished with previous data load.
var statsDS;
function generateStatsDS() {
// create the Data Store
// App Control Combo Data Store
statsDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: './includes/database/dbmanager.php'
}),
// create reader that reads the records
reader: new Ext.data.JsonReader({},['numMembers', 'numClasses'])
});
statsDS.baseParams.func = "getStats";
statsDS.load({params: {func: 'getStats'}}, {callback:renderStats()}, {scope:this});
}
//* r : Ext.data.Record[]
//* options: Options object from the load call
//* success: Boolean success indicator
Also below, it makes a callback to the 'renderStats()' function once this load is complete.
function renderStats(r, options, success) {
var numMembers = statsDS.getAt(0).data.numMembers;
var numClasses = statsDS.getAt(0).data.numClasses;
// Render statistics
Ext.get('numMembers').dom.innerHTML = numMembers;
Ext.get('numClasses').dom.innerHTML = numClasses;
}
However, my problem is that from a scoping standpoint, parameters: r, options, success have no value and aren't defined as stated in the API docs: http://extjs.com/deploy/ext/docs/output/Ext.data.Store.html#load
Is the Scoping correct or am I missing something. While stepping through with firebug, it is not defined.
Thoughts? Ideas?