我尝试动态更新HandsonTable设置。设置似乎会更新,但渲染表仍使用以前的设置。
示例:http://jsfiddle.net/kAFWA/30/
updateSettings文档:http://docs.handsontable.com/0.18.0/Core.html#updateSettings
var ht;
$(document).ready(function() {
$("#example1").handsontable({
minRows: 5,
minCols: 5,
colHeaders: ["Header 1", "Header 2", "Header 3"],
rowHeaders: true,
contextMenu: {
items: {
"edit_Header": {
name: "Edit this Header!!"
}
}
}
});
ht = $('#example1').handsontable("getInstance");
});
function updateContextMenu() {
console.log(ht);
ht.updateSettings({
minRows: 4,
minCols: 4,
colHeaders: ["Header 4", "Header 5", "Header 6"],
contextMenu: {
items: {
"edit_Header": {
name: "Another Text"
},
}
}
}, true);
console.log('here');
ht.render();
}<link href="http://handsontable.com/dist/jquery.handsontable.full.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://handsontable.com/dist/jquery.handsontable.full.js"></script>
<div id="example1" class="handsontable"></div>
<p>
<button type="button" name="update" title="Update context menu" onclick="updateContextMenu()">Update context menu</button>
</p>
发布于 2015-10-15 03:28:39
是的,所以你想去掉updateSettings的第二个参数。不确定它是做什么的,但是如果你在你的小提琴里把它去掉了,它就会正确更新。仅供参考,不需要重新渲染,因为它无论如何都会在结束时重新渲染。
https://stackoverflow.com/questions/33127744
复制相似问题