SpreadJS 14
Frequently Used Events / Use Events when Clicking a Button
In This Topic
    Use Events when Clicking a Button
    In This Topic

    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");
         }
    });