我下载了一个网格:ParamQuery 网格,我需要向其中添加项目,我对 javascript 很陌生,但正如我所见,它使用了一个变量数据,它将其记录保存在数组数组中,如下所示:
var data = [['hello','byebye']]
我需要从 ini 文件中添加这些记录,所以现在我有这样的代码:
$(function () {
var allText =[];
var allTextLines = [];
var Lines = [];
var txtFile = new XMLHttpRequest();
var linenumber = 0;
var data = new Array();
txtFile.open("GET", "automaticlang_EN.ini", true);
allText = txtFile.responseText;
txtFile.onreadystatechange = function()
{
if (txtFile.readyState == 4)
{
// Makes sure it's found the file.
allText = txtFile.responseText;
allTextLines = allText.split(/\r\n|\n/);
var data = new Array([allTextLines]);
console.log(data[0]);
} else {
}
}
txtFile.send(null)
//console.log(data);
//var data = [['hello','byebye']] //this works
var obj = { width: 700, height: 700, title: "Translation Grid",resizable:true,draggable:true };
obj.colModel = [{ title: "ID", width: 100, dataType: "string" },
{ title: "Translation", width: 200, dataType: "string" }];
obj.dataModel = { data: data };
$("#grid_array").pqGrid(obj);
});
我没有给我结果我做错了什么?