想在頁面中做類似excel的操作,發現handsontable符合要求。
然后發現這個文章
http://blog.csdn.net/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>';