非常感谢,另外我是对某一个固定的单元格进行日期操作的,现在问题是其他单元格都弹出日期了。我的版本是9.0的。麻烦帮我看下。谢谢了 var ns = GcSpread.Sheets;
function DatePickerCellType() {
}
DatePickerCellType.prototype = new ns.CustomCellType();
DatePickerCellType.prototype.createEditorElement = function (context) {
//Create input presenter.
var input = document.createElement("input");
return input;
};
DatePickerCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
//Initialize input editor.
if (editorContext) {
$editor = $(editorContext);
ns.CustomCellType.prototype.activateEditor.apply(this, arguments);
$editor.datepicker();
$editor.css("position", "absolute");
$editor.attr("gcUIElement", "gcEditingInput");
$(".ui-datepicker").attr("gcUIElement", "gcEditingInput");
}
}
DatePickerCellType.prototype.deactivateEditor = function (editorContext, context) {
//Remove input editor when end editor status.
if (editorContext) {
var element = editorContext;
$(element).datepicker("hide");
$(element).datepicker("destroy");
}
ns.CustomCellType.prototype.deactivateEditor.apply(this, arguments)
};
DatePickerCellType.prototype.setEditorValue = function (editor, value, context) {
//Sync value from Cell value to editor value.
$(editor).datepicker("setDate", value);
};
DatePickerCellType.prototype.getEditorValue = function (editor, context) {
//Sync value from editor value to cell value.
return $(editor).datepicker("getDate");
};
DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
if (editorContext) {
$editor = $(editorContext);
$editor.css("width", cellRect.width - 1);
$editor.css("height", cellRect.height - 3);
}
};
------上面是通用的,下面我对整个表格进行遍历操作具体哪个表格是日期---或者直接赋值具体哪个单元格操作也不行--
for (var i = 0; i < spread.sheets[0].getRowCount() ; i++) {
for (var j = 0; j < spread.sheets[0].getColumnCount() ; j++) {
spread.sheets[0].getCell(2, 2).text(0, 1, "DatePicker");
var range = spread.sheets[0].getCell(2,2);
range.cellType(new DatePickerCellType());
range.formatter("yyyy年MM月dd日");
}
}
|