我发现时我自定义了一个cellType
function NumberCellType(){
}
//console.log('CellTypes: ',spreadNS.CellTypes);
NumberCellType.prototype = new spreadNS.CellTypes.Text();
NumberCellType.prototype.createEditorElement = function(context) {
//Creates a DOM element then returns it.
var editor = spreadNS.CellTypes.Text.prototype.createEditorElement.call(this, context);
//console.log('editor',this, editor , context);
var textarea = editor;
//textarea.setAttribute("onkeydown", "valideInput()");
var removeNoNumber = function(){
var textarea = this;
var value = textarea.value
if(value && value.length && !$.isNumeric(value)){
textarea.value = '';
}
}
textarea.onkeydown = removeNoNumber;
textarea.onkeyup = removeNoNumber;
textarea.onchange = removeNoNumber;
return editor;
};
NumberCellType.prototype.max = function(context) {
}
NumberCellType.prototype.min = function(context) {
}
然后设置某个单元格我自定义的CellType
sheet.setCellType(sel.row + r, sel.col + c, cellType, spreadNS.SheetArea.viewport);
然后toJSON之后,我自定义的单元格的json为
"6" : {
"value" : "111",
"style" : {
"autoFormatter" : {},
"cellType" : {
"b5" : {},
"c5" : {},
"jK" : null
}
}
}
在spread.fromJSON的时候就会出错
请问我的自定义cellType应该怎么改才能toJSON, fromJSON |