问题
当采用自定义数据结构时,双击单元格,input框中的值变成了’[object Object]’,保存之后也不能正常显示。
解决方法
一、 直接自己重写一个editor
二、相对简单点,重写textarea这个editor中的prepare方法和saveValue方法
import * as handsontable from 'handsontable'; //如果采用js写的,require即可
var CustomEditor = handsontable.editors.BaseEditor;
CustomEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) {
// 把originValue的值替换成你要显示的值即可 如:
this.TD = td;
this.row = row;
this.col = col;
this.prop = prop;
this.originalValue = showValue;
this.cellProperties = cellProperties;
this.state = EditorState.VIRGIN;
}
CustomEditor.prototype.saveValue = function (value, ctrlDown) {
// 保存到对应对象上即可
}