SpreadJS Documentation
Using the Button Clicked Event with Cells
SpreadJS Documentation > Sample Code > Sample Code for Cells > Using the Button Clicked Event with Cells

You can use the ButtonClicked event with button, check box, or hyperlink cells.

The ButtonClicked event occurs when the user clicks a button, check box, or hyperlink in a cell.

Using Code

This example displays a message when you click on the button cell.

JavaScript
Copy Code
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
activeSheet.setCellType(1,1,cellType);

spread.bind(GC.Spread.Sheets.Events.ButtonClicked, function (e, args) {
   var sheet = args.sheet, row = args.row, col = args.col;
   var cellType = activeSheet.getCellType(row, col);
   if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
       alert("Button Clicked");
   }
});