Posted 19 May 2021, 6:32 pm EST
Hi Shanmukha,
For this, you need to override the paintValue method of ButtonCellType class. Please refer to the following code snippet and attached sample that demonstrates the same.
let oldPaintValue = GC.Spread.Sheets.CellTypes.Button.prototype.paintValue;
GC.Spread.Sheets.CellTypes.Button.prototype.paintValue = function (
ctx,
value,
x,
y,
w,
h,
style,
options
) {
var self = this,
marginLeft = self._marginLeft,
marginTop = self._marginTop;
var startX = x + marginLeft,
startY = y + marginTop,
width = w - marginLeft - self._marginRight,
height = h - marginTop - self._marginBottom;
let buttonState = style.cellType._buttonState;
//if the state is click then fill the button with custom style
if (buttonState === 2) {
ctx.fillStyle = "cyan";
style.cellType._buttonState = 2;
ctx.fillRect(startX + 1, startY + 1, width - 2, height - 2);
if (this._text) {
GC.Spread.Sheets.CellTypes.Text.prototype.paintValue.call(
self,
ctx,
this._text,
startX,
startY,
width,
height,
style,
options
);
}
return;
}
oldPaintValue.apply(this, arguments);
};
sample: https://codesandbox.io/s/beautiful-perlman-p8ohc?file=/src/index.js:266-1367
Regards,
Avinash