handsontable合并表头

本文详细介绍了如何在使用Handsontable实现多表头时,遇到的删除按钮列显示错误的问题,并提供了修改代码解决方法。

想在页面中做类似excel的操作,发现handsontable符合要求。

然后发现这个文章

http://blog.youkuaiyun.com/wynan830/article/details/9054195

该作者扩展了handsontable实现了多表头。

同时添加了removeRowPlugin属性,作用是在每行前面显示一个删除按钮执行删除操作。

我的页面中不需要删除,因此把removeRowPlugin设置为false。但是表头出现了错行。

查看生成的html发现,表头中多了一列:<th class="htNoFrame htRemoveRow"></th>。

在css中添加

.handsontable th.htNoFrame.htRemoveRow {
width:0px
}

不起作用。PS:我添加的这个CSS写法是不是有问题?

在jquery.handsontable.js里原作者添加了treeToth函数,处理多表头

原代码为:

datastr += '<tr>';
 datastr += '<th class="htNoFrame htRemoveRow"></th>';
 datastr += '<th ></th>';

可见没有判断是否需要显示删除按钮列

修改为:

datastr += '<tr>';
if (userSettings.removeRowPlugin != null && userSettings.removeRowPlugin) {
       datastr += '<th class="htNoFrame htRemoveRow"></th>';
   }
datastr += '<th ></th>';

 

转载于:https://www.cnblogs.com/darksied/p/4888719.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值