Javascript 在jexcel更新表之后,我没有得到新的值
我无法获取新的JetXcel数据。 当我单击“保存测试列数据”“不工作”时。我必须得到总数 [ [ “本田”, "2", "2", "" ] ]Javascript 在jexcel更新表之后,我没有得到新的值,javascript,spreadsheet,Javascript,Spreadsheet,我无法获取新的JetXcel数据。 当我单击“保存测试列数据”“不工作”时。我必须得到总数 [ [ “本田”, "2", "2", "" ] ] 这是我的密码 var datagrid = jexcel(document.getElementById('my-spreadsheet'), { columns: [ {title: 'Model', width: 300}, {title: 'Price', type: 'numeric', widt
这是我的密码
var datagrid = jexcel(document.getElementById('my-spreadsheet'), {
columns: [
{title: 'Model', width: 300},
{title: 'Price', type: 'numeric', width: 80},
{title: 'Tax', type: 'numeric', width: 100},
{title: 'Test', type: 'numeric', width: 100}
],
data: [
['Honda']
],
updateTable: function (instance, cell, col, row, val, label, cellName) {
if (col == 1) {
Price = val;
}
if (col == 2) {
Tax = val;
}
if (col == 3) {
totals = Number(Price) + Number(Tax);
$(cell).text(totals);
}
}
});
function save() {
var data = datagrid.getJson();
console.log(data, 'data');
}
我知道有一个公式像=B1+C1。。。
但是我已经手动输入了网格中的所有行
事实上,它在jexcel 1.5版中按预期工作,您正在从单元格中更改innerHTML,而不更改数据源对象。您可以使用以下代码修复此问题:
var datagrid = jexcel(document.getElementById('my-spreadsheet'), {
columns: [
{title: 'Model', width: 300},
{title: 'Price', type: 'numeric', width: 80},
{title: 'Tax', type: 'numeric', width: 100},
{title: 'Test', type: 'numeric', width: 100}
],
data: [
['Honda']
],
updateTable: function (instance, cell, col, row, val, label, cellName) {
if (col == 1) {
Price = val;
}
if (col == 2) {
Tax = val;
}
if (col == 3) {
totals = Number(Price) + Number(Tax);
// Update labels
$(cell).text(totals);
// Update data source
instance.jexcel.options.data[y][x] = totals;
}
}
});
什么不起作用?