|
@@ -207,5 +207,55 @@ var sheetCommonObj = {
|
|
|
}
|
|
|
}
|
|
|
return rst;
|
|
|
+ },
|
|
|
+ //add by zhong 2017-10-10
|
|
|
+ //动态下拉框,配合EnterCell, args.sheet.repaint();
|
|
|
+ getDynamicCombo: function () {
|
|
|
+ let ComboCellForActiveCell = function () { };
|
|
|
+ ComboCellForActiveCell.prototype = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
+ ComboCellForActiveCell.prototype.paintValue = function (ctx, value, x, y, w, h, style, options) {
|
|
|
+ let sheet = options.sheet;
|
|
|
+ if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
|
|
|
+ GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ GC.Spread.Sheets.CellTypes.Base.prototype.paintValue.apply(this, arguments);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ ComboCellForActiveCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, options) {
|
|
|
+ let sheet = options.sheet;
|
|
|
+ if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
|
|
|
+ return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return GC.Spread.Sheets.CellTypes.Base.prototype.getHitInfo.apply(this, arguments);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return new ComboCellForActiveCell();
|
|
|
+ },
|
|
|
+ setDynamicCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
|
|
|
+ let me = this;
|
|
|
+ sheet.suspendPaint();
|
|
|
+ for(let i = 0, len = rowCount; i < len; i++){
|
|
|
+ let combo = me.getDynamicCombo();
|
|
|
+ if(itemsHeight) combo.itemHeight(itemsHeight);
|
|
|
+ if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
+ else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
+ else combo.items(items);
|
|
|
+ sheet.getCell(beginRow + i, col).cellType(combo);
|
|
|
+ }
|
|
|
+ sheet.resumePaint();
|
|
|
+ },
|
|
|
+ setStaticCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
|
|
|
+ sheet.suspendPaint();
|
|
|
+ for(let i = 0, len = rowCount; i < len; i++){
|
|
|
+ let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
+ if(itemsHeight) combo.itemHeight(itemsHeight);
|
|
|
+ if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
+ else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
+ else combo.items(items);
|
|
|
+ sheet.getCell(beginRow + i, col).cellType(combo);
|
|
|
+ }
|
|
|
+ sheet.resumePaint();
|
|
|
}
|
|
|
}
|