大家好。
我有一个任务:制作自定义 header ,好吧, header 本身已制作,但我遇到了以下麻烦:
我有自定义 html 字符串作为 header ,即:
var str = "
<tr><th colspan='2'>global</th><tr>
<tr><th><img src='generateonflypath' /></th><th><img src='generateonflypath' /></th><tr>
"
当我像这样应用它时:
$hotContainer.handsontable({
afterRender: function () {$('.htCore > thead').html(str);}
});
我的 HOT 高度保持不变,最低的行是看不见的,直到我单击任何单元格。 如何解决这个问题? (“beforerender”事件效果更差)
感谢您的宝贵时间!
最佳答案
经过几天的粗略实验,我得到了这个解决方案:
$container.handsontable({
...options...
afterRender: function () { //add custom header
$('.htCore > thead').html(jsonObj.Headers);
//add container resize event handler for images that loaded in header
$('.htCore > thead img').load(function(){
$('.wtHider').height($('.htCore').height()+10);
});
}
});
这背后的想法是改变 HOT 主表容器的高度。 我认为其他人可以对其他事件做同样的事情,不仅加载img,还可以更改文本等...
希望这对某人有帮助!
关于javascript - 可手动自定义 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18526081/