SpreadJS 14
Frequently Used Events / Use Events when Range Changes
In This Topic
    Use Events when Range Changes
    In This Topic

    You can use code when the cell range of table range changes. Using Code

    This example uses the RangeChanged event.

    JavaScript
    Copy Code
    // Initializing Spread
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
    // Get the activesheet
    var activeSheet = spread.getSheet(0);
    // Add data
    for (var col = 1; col < 6; col++) {
        for (var row = 2; row < 11; row++) {
            activeSheet.setValue(row, col, row + col);
        }
    }
    for (var col = 7; col < 12; col++) {
        for (var row = 2; row < 5; row++) {
            activeSheet.setValue(row, col, row + col);
        }
    }
    // Add tables
    activeSheet.tables.add("Table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.dark1);
    activeSheet.tables.add("Table2", 1, 7, 4, 5, GC.Spread.Sheets.Tables.TableThemes.dark1);
    
    // Bind RangeChanged event
    activeSheet.bind(GC.Spread.Sheets.Events.RangeChanged, function (sender, args) {
        if (args.tableNames) {
            console.log("RangeChanged event fired for Table : " + args.tableNames);
        }
    });