in html i'm dynamically creating a table:
function createTable()
{
var tablecontents = "";
tablecontents = "<table>";
tablecontents += "<tr>";
for (var i = 0; i < 12; i ++)
{
tablecontents += "<td>";
tablecontents += '<div data-dojo-type="com.Control" id="Control' + i + '" style="width: 143px; height: 200px;"/>' ;
tablecontents += "</td>";
}
tablecontents += "</tr>";
for(var z = 0; z < 12; z++)
{
tablecontents += "<tr>";
tablecontents += "<td>";
tablecontents += 'C';
tablecontents += "</td>";
tablecontents += "<td>";
tablecontents += '<div data-dojo-type="com.Control" id="ControlTwo' + z + '" style="width: 40px; height: 20px;"/>' ;
tablecontents += "</td>";
tablecontents += "<td>";
tablecontents += 'B'
tablecontents += "</td>";
tablecontents += "<td>";
tablecontents += 'A'
tablecontents += "</td>";
tablecontents += "<td>";
tablecontents += '2010'
tablecontents += "</td>";
tablecontents += "<td>";
tablecontents += '<div data-dojo-type="com.Control" id="ControlThree' + z + '" style="width: 40px; height: 20px;"/>' ;
tablecontents += "</td>";
tablecontents += "</tr>";
}
tablecontents += "</table>";
document.getElementById("graphicalData").innerHTML = tablecontents;
}
I want to populate this table with data retrieved from a CSV file so i wrote the following code:
ready(function() {
//programmatically reading CSV from external file
var personStoreForGrid = new dojox.data.CsvStore({
url:"datasheet.csv"
});
//storing to DataStore
var objectStore = dojo.store.DataStore({
store: personStoreForGrid
});
objectStore.query().then(function(results)
{
//results contains everything from csv file
});
createTable();
parser.parse();
});
in this case, the table gets created before i'm able to obtain the results from the csv file. How to i reverse this so i can grab the contents just before going to create the table?
Very new to Dojo!
As you already wrote
objectStore.query().then(function(results)
{
//results contains everything from csv file
});
it's deferred/async action, you need to create it when it finishes query something like
objectStore.query().then(lang.hitch(this, function(results) {
//results contains everything from csv file
this.createTable();
}));
where lang is dojo/_base/lang
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.