I am attempting to create an html table that joins GIS Map output with a dojox csv store. This is performed through a series of function calls. The resulting behavior is that in IE, I need to fire (onclick event on the map) the parent function twice to get the joined data (ChildFoo) from the csvStore to appear. It's like the parent function (Identify) is returning a value (infoWindow) before the callback function is completed. However in FF this does not work at all with firebug reporting "callback not defined".
I believe I may be using the fetch completely out of context for what I trying to accomplish. The csv files are small (<300 records with 10 fields) - is there a better way to fetch a sub-set, then iterate through adding fields to an html table?
Below is a pseudo-code of the functions I'm using:
function Identify{
infoWindow = "";
var store = new dojox.data.CsvStore({ url: "data/ChildFooData.csv", label:"ChildFoo" });
// some GIS code in here creates an array = GISResults
//handle multiple results found
for (var i=0, GISResults.length; i<il; i++) {
//this may result in a number of stacked html tables
infoWindow = infoWindow + MasterFoo(GISResults);
}
//a dojo contentpane gets updated with infoWindow value
GISmap.showinfoWindow;
}
function MasterFoo(MasterFooArray){
content="";
// iterate through master records from GIS map identify
for (var i=0, i < masterFoo.length; i++) {
content+="<table><tr><td>" + MasterFooID + "</td> </tr>"
store.fetch({query: {MasterFooID:MasterFoo[i].ID},onComplete:callback});
// Insert all related children records
callback(items){
for (var l = 0; l < items.length; l++) {
content += "<tr><td> + store.getValue(items[l], "ChildFoo_ID") + </td></tr>"
content += "<tr><td> + store.getValue(items[l], "ChildFoo_Desc") + </td></tr>"
}
}
// we're done, close the table and return html string to parent function
content+="</table>"
return content;
}