gpt4 book ai didi

javascript - Handsontable:jquery 合并标题,水平滚动时的错误

转载 作者:太空狗 更新时间:2023-10-29 16:45:40 25 4
gpt4 key购买 nike

我目前正在使用 handsontable 和 python+django,我用 Javascript 放置了一个自定义合并 header 。这应该是这样的。

但是当我加载页面时。

enter image description here

但是,当我向后滚动并向前滚动时,错误神奇地消失了。

enter image description here

这是容器 div。

<div class="table-container" style="width: auto; height: 200px; overflow: hidden;margin-top: 20px;">
<div id="table-index" data-productoscomerciales='{{productoscomerciales}}'></div>
</div>

这是我的 javascript 代码。

function createTable(data, container) {    

var str = '<tr id="header-grouping">'+'<th colspan="1"></th>'+'<th colspan="1"></th>'+'<th colspan="1"></th>'+'<th colspan="15">Inventario*</th>' +
'<th colspan="9">Producción*</th>'+'</tr>';

return new Handsontable(container, {
data: data.slice(2,data.length),
minSpareRows: 1,
rowHeaders: false,
manualColumnResize: true,

colHeaders: data[0],
columns: data[1],

colWidths: [150, 100, 130],
contextMenu: false,
afterRender : function () {$('.htCore > thead > tr').before(str);},
beforeRender: function() {
while ($('#header-grouping').size() > 0)
$('#header-grouping').remove();
},
afterColumnResize: function () {
$container.handsontable('render');
},
afterGetColHeader: function() {
while ($('.ht_clone_top.handsontable #header-grouping th').size() > 0)
$('.ht_clone_top.handsontable #header-grouping th').remove();
}
});

最佳答案

我想我知道出了什么问题。删除 afterRender,它应该会自行修复。你遇到的问题是你试图修改 Handson 呈现的表格上的 html,这总是一个坏主意。 Handson 会相当频繁地重新呈现,例如当您滚动或单击时,这意味着该行在使用表格几秒钟后就毫无用处了。

关于javascript - Handsontable:jquery 合并标题,水平滚动时的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32229131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com