Return 使用 .getSourceData 来自 Handsontable 的 nxn 数据数组
Return nxn array of Data from Handsontable using .getSourceData
我正在尝试使用 .getSourceData method. The console logs an array of arrays if I call the method using no optional parameters however when I attempt to pass these parameters I get console errors. I have a Fiddle 从 "handsontable" 获取源数据对象,它可以输出数组但如果我取消注释可选参数方法则不起作用。
var data = [
[0, 0, 0],
[10, 0.1, 150],
[20, 0.2, 151]
]
var container1 = document.getElementById('Table'),
hot1;
var hot1 = new Handsontable(container1, {
data: data,
colHeaders: ['Measured Depth', "Inclination", "Azimuth"],
rowHeaders: true,
minSpareRows: 0,
contextMenu: ['row_above', 'row_below', 'remove_row']
});
function countRows() {
var ht = hot1
var rowcount = ht.countRows() - ht.countEmptyRows();
return rowcount;
}
console.log(countRows())
function submitForm() {
var htContents = hot1.getSourceData() //getSourceData(1,1,countRows(),3)
console.log(htContents);
}
$("#get_data").click(submitForm);
我从来没有让那个函数起作用,但是起作用的是使用 countRows() 来限制我的输出返回空白,即
for (i = 0; i < countRows(); i++) {
md.push(htContents[i][0]);
inc.push(htContents[i][1]);
azi.push(htContents[i][2]);
}
我正在尝试使用 .getSourceData method. The console logs an array of arrays if I call the method using no optional parameters however when I attempt to pass these parameters I get console errors. I have a Fiddle 从 "handsontable" 获取源数据对象,它可以输出数组但如果我取消注释可选参数方法则不起作用。
var data = [
[0, 0, 0],
[10, 0.1, 150],
[20, 0.2, 151]
]
var container1 = document.getElementById('Table'),
hot1;
var hot1 = new Handsontable(container1, {
data: data,
colHeaders: ['Measured Depth', "Inclination", "Azimuth"],
rowHeaders: true,
minSpareRows: 0,
contextMenu: ['row_above', 'row_below', 'remove_row']
});
function countRows() {
var ht = hot1
var rowcount = ht.countRows() - ht.countEmptyRows();
return rowcount;
}
console.log(countRows())
function submitForm() {
var htContents = hot1.getSourceData() //getSourceData(1,1,countRows(),3)
console.log(htContents);
}
$("#get_data").click(submitForm);
我从来没有让那个函数起作用,但是起作用的是使用 countRows() 来限制我的输出返回空白,即
for (i = 0; i < countRows(); i++) {
md.push(htContents[i][0]);
inc.push(htContents[i][1]);
azi.push(htContents[i][2]);
}