如何在 Handsontable 中将旧的 table 替换为新的?
How to replace old table with new one in Handsontable?
我有一个界面,允许用户输入 MySQL 查询并单击按钮执行查询。然后查询的结果显示在由 Handsontable 创建的 table 中。我用下面的代码来做:
var output = document.getElementById("output");
var hot = new Handsontable(output, table_setting);
现在的问题是,每次单击按钮时,都会在旧按钮上创建一个新的 table。我想用新的来代替旧的。我尝试在 var hot = new Handsontable(output, table_setting);
之前使用 output.innerHTML = "";
来摆脱旧的 table。这似乎摆脱了旧的 table,但新的 table 不再出现。最好的方法是什么?
谢谢!
您想先执行 hot.destroy()
然后创建一个新的 hot
实例。
我有一个界面,允许用户输入 MySQL 查询并单击按钮执行查询。然后查询的结果显示在由 Handsontable 创建的 table 中。我用下面的代码来做:
var output = document.getElementById("output");
var hot = new Handsontable(output, table_setting);
现在的问题是,每次单击按钮时,都会在旧按钮上创建一个新的 table。我想用新的来代替旧的。我尝试在 var hot = new Handsontable(output, table_setting);
之前使用 output.innerHTML = "";
来摆脱旧的 table。这似乎摆脱了旧的 table,但新的 table 不再出现。最好的方法是什么?
谢谢!
您想先执行 hot.destroy()
然后创建一个新的 hot
实例。