[{"id":"ca257e3e-9292-470e-9d7a-096b7c93a20e","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"86f1e123-ff2a-4ea0-a255-1c563fd53a4c","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"48d62b40-1243-44d3-bb0c-20b1335e100e","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"a479940a-f4be-4b31-a8fe-21d04270b6b3","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"dc5879f1-1f4e-415e-9d68-234f475c6ffb","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"e0f082cd-9797-4731-a08b-29ba133811cc","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"62fc4bd3-ab67-44d6-986f-2fe4c9558bdb","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"140ce507-8f59-4038-9016-33c5efc6837c","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"996f6920-d668-4adf-808a-356cee2027d0","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"fae22100-16a8-4d38-9b42-377af58552f4","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"14c6b426-94eb-4b0f-8803-3dae265130bd","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"29ea6a57-be42-4ee1-9ea1-4556452433e2","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"133b00a6-e011-4383-8723-46ac57dd361c","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"95e6d892-7bcd-4f6a-a152-504dec37c741","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"ff2fda3b-2365-49e2-ac9d-552284e45c73","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"3a7fa7b2-f252-436c-a1d1-5dd3c39a51ca","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"612ac80c-894b-4ae5-9ddc-5ff5cc2d0e8d","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"8f38e4df-4e2a-4a3a-ad58-6455d17b2506","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"a5da5dfc-4538-4c30-bb2b-654ffab99ffc","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"56963b79-20a3-4e91-9154-6bb0620b8ef7","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"6a9a4310-c4ee-49e1-9d51-6e2ebf757af4","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"b9d50243-49fa-405e-8804-7952197967b8","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"fa6afaf7-2038-42b0-8d43-86dfe46042cd","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"119624ed-fc48-46e9-aa43-89d7e2642cae","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"a6083f9e-9f9f-4a8e-96de-a043142d0282","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"5fdbcfd3-89c6-4a0c-83f0-a42fe72ba1f2","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"091efdad-d40d-4a8f-80de-a4332c0d6cfa","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"1dfbf182-8b10-492f-af29-a693d3db1ba5","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"6c0fdf26-682b-4deb-a278-ab57684d2cdc","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"46ac94dc-0e36-4cf5-a4b6-ad12b290f7b0","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"bd521645-2c83-4f3d-82ff-b17fa70faacd","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"36dc7e35-c17b-401d-b90f-b2141363afd0","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"fb1e533a-d61d-423a-ac26-beea6046ac5c","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"07e7a0bb-cca2-4bf8-84f8-caea8571c631","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"a250185e-b09b-4a0f-8c42-dade416924a4","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"6ea790e0-5d8e-4666-bba8-e344abbca974","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"165ce06c-c29a-458e-9ea9-e362afa3407d","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"f9c5b950-f2ab-4fc6-b584-e3f2f9150fae","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]},{"id":"038db070-9dd8-4837-9c23-e8289b588bae","tags":[{"name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce"}]},{"id":"21eb86b7-ba90-4b53-8576-fd57998f80bd","tags":[{"name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99","links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d"}]}]
The following sections provide code samples for various events available in SpreadJS.
You can configure events for when a cell is clicked in a SpreadJS worksheet.
The following code sample shows how to use the CellClick event.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
var activeSheet = spread.getActiveSheet();
activeSheet.bind(GC.Spread.Sheets.Events.CellClick,
function (sender, args)
{
if(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader)
{
console.log("The column header was clicked.");
}
if(args.sheetArea === GC.Spread.Sheets.SheetArea.rowHeader)
{
console.log("The row header was clicked.");
}
if(args.sheetArea === GC.Spread.Sheets.SheetArea.corner){
console.log("The corner header was clicked.");
}
console.log("Clicked column index: " + args.col);
console.log("Clicked row index: " + args.row);
});
You can configure events for when a cell is double-clicked in a SpreadJS worksheet.
The following code sample shows how to use the CellDoubleClick event.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
var activeSheet = spread.getActiveSheet();
activeSheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args)
{
if(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader)
{
console.log("The column header was double clicked.");
}
if(args.sheetArea === GC.Spread.Sheets.SheetArea.rowHeader)
{
console.log("The row header was double clicked.");
}
if(args.sheetArea === GC.Spread.Sheets.SheetArea.corner)
{
console.log("The corner header was double clicked.");
}
console.log("Double clicked column index: " + args.col);
console.log("Double clicked row index: " + args.row);
});
You can use events when moving a cell.
The following code sample shows how to use the LeaveCell event.
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
var activeSheet = spread.getActiveSheet();
activeSheet.bind(GC.Spread.Sheets.Events.LeaveCell, function (sender, args)
{
console.log("The column index before moving: " + args.col);
console.log("The row index before moving: " + args.row);
});
You can use events when edit mode starts or stops.
The following code sample shows how to use the EditStarting and EditEnded events.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
var activeSheet = spread.getActiveSheet();
activeSheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args)
{
console.log("Start cell editing.");
});
activeSheet.bind(GC.Spread.Sheets.Events.EditEnded, function (sender, args)
{
console.log("Finish cell editing.");
});
You can use events when the data in a cell changes.
The following code sample shows how to use the EditChange event.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
var activeSheet = spread.getActiveSheet();
activeSheet.bind(GC.Spread.Sheets.Events.EditChange, function (sender, args)
{
console.log("Cell (" + args.row + ", " + args.col + ") data has been changed.")
});
You can use events when the top row or column changes when scrolling.
The following code sample shows how to use the TopRowChanged and LeftColumnChanged events.
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
spread.addSheet();
var sheet1 = spread.getSheet(0),
sheet2 = spread.getSheet(1);
sheet1.bind(GC.Spread.Sheets.Events.TopRowChanged, function (sender, args)
{
/* Set the displayed top row of sheet1 to sheet2
(vertical scroll synchronization). */
sheet2.showRow(args.newTopRow, GC.Spread.Sheets.VerticalPosition.top);
});
sheet1.bind(GC.Spread.Sheets.Events.LeftColumnChanged, function (sender, args)
{
/* Set the displayed left column of sheet1 to sheet2
(Horizontal scroll synchronization). */
sheet2.showColumn(args.newLeftCol, GC.Spread.Sheets.HorizontalPosition.left);
});
You can use events when the sheet tab changes.
The following code sample shows how to cancel the tab change.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
spread.addSheet();
spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanging,
function (sender, args)
{
// Cancel sheet switching.
args.cancel = true;
});
spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanged, function (sender, args)
{
console.log("Active sheet has been switched.");
});
You can use events when dragging and dropping a block of cells.
The following code sample shows how to use the DragDropBlock event.
var spread =
new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
{sheetCount:3});
var sheet = spread.getActiveSheet();
sheet.bind(GC.Spread.Sheets.Events.DragDropBlock, function (e, args)
{
console.log("From Column:" + args.fromCol);
console.log("From Row:" + args.fromRow);
console.log("To Column:" + args.toCol);
console.log("To Row:" + args.toRow);
});
You can configure an event before a sheet is changed or after a sheet is changed.
The SheetChanging event is fired before a sheet is changed whereas a SheetChanged event is fired after a sheet is changed. The sheet changes here include inserting, deleting, hiding, or unhiding a sheet by using the context menu or clicking the "+" button in the sheet tab.
The following code sample shows how to use the SheetChanged and SheetChanging events.
// initializing Spread
var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
// Bind SheetChanged event
spread.bind(GC.Spread.Sheets.Events.SheetChanged, function (sender, args) {
console.log("Changed type: " + args.propertyName + " & Sheet Index : " + args.sheetIndex);
});
// Bind SheetChanging event
spread.bind(GC.Spread.Sheets.Events.SheetChanging, function (sender, args) {
console.log("Changing type: " + args.propertyName + " & Sheet Index : " + args.sheetIndex);
});
You can use code when the cell range of a table range changes.
The following code sample shows how to use the RangeChanged event.
// 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);
}
});
You can use the ButtonClicked event with a button, check box, or hyperlink cells.
The ButtonClicked event occurs when the user clicks a button, check box, or hyperlink in a cell.
The following code sample shows how to display a message when you click on the button cell.
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");
}
});