1金币
本帖最后由 Lynn.Dou 于 2021-11-15 12:26 编辑
- function DatePickerCellType() {
- }
- DatePickerCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
- DatePickerCellType.prototype.createEditorElement = function () {
- //Create input presenter.
- var input = document.createElement("input");
- return input;
- };
- DatePickerCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
- //Initialize input editor.
- if (editorContext) {
- $editor = $(editorContext);
- GC.Spread.Sheets.CellTypes.Base.prototype.activateEditor.apply(this, arguments);
- $editor.datetimepicker();
- $editor.css("position", "absolute");
- $editor.attr("gcUIElement", "gcEditingInput");
- $(".ui-datetimepicker").attr("gcUIElement", "gcEditingInput");
- }
- }
- DatePickerCellType.prototype.deactivateEditor = function (editorContext) {
- //Remove input editor when end editor status.
- if (editorContext) {
- var element = editorContext;
- $(element).datetimepicker("hide");
- $(element).datetimepicker("destroy");
- }
- GC.Spread.Sheets.CellTypes.Base.prototype.deactivateEditor.apply(this, arguments)
- };
- DatePickerCellType.prototype.setEditorValue = function (editor, value) {
- //Sync value from Cell value to editor value.
- $(editor).datetimepicker("setDate", value);
- };
- DatePickerCellType.prototype.getEditorValue = function (editor) {
- //Sync value from editor value to cell value.
- return $(editor).datetimepicker("getValue");
- };
- DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect) {
- if (editorContext) {
- $editor = $(editorContext);
- $editor.css("width", cellRect.width - 1);
- $editor.css("height", cellRect.height - 3);
- }
- };
复制代码 基于这个例子:https://demo.grapecity.com.cn/SpreadJS/cdn/extendedExample/#/demos/datePickerCell
依赖jQuery-datetimepicker 始终无法将选择的日期填入单元格,getEditorValue 方法始终无法拿到日期值
jquery-datetimepicker: https://xdsoft.net/jqplugins/datetimepicker/
|
|