之前介绍了如何双击修改列标题,但是在点击handsontable的表体的时候,并没有失去焦点,如何解决呢?其实也不难,监听鼠标的点击事件即可,具体代码如下:
htable.rootElement.onclick = function(e) {
<span style="white-space:pre"> </span>// 列标题编辑状态下,点击handsontable,失去列标题编辑框焦点
<span style="white-space:pre"> </span>var childs = this.getElementsByClassName("column_name_edit");
<span style="white-space:pre"> </span>if (childs.length == 1 && e.target.className != "column_name_edit") {
<span style="white-space:pre"> </span>childs[0].blur();
<span style="white-space:pre"> </span>}
}