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();
},
想要实现一个自定义的单元格, 下拉框只有在焦点进入单元格了才出现,焦点移除下拉框消失, 不在EnterCell事件中添加sheet.repaint()方法的话无法达到效果,用了repaint()方法会导致性能问题 |