在 html 中,我正在动态创建一个表:
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;
}
我想用从 CSV 文件中检索到的数据填充此表,因此我编写了以下代码:
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();
});
在这种情况下,在我能够从 csv 文件中获取结果之前创建了表。我如何扭转这一点,以便我可以在创建表格之前获取内容?
对 Dojo 非常陌生!