SpreadJS provides events for the sheet. You can have the application perform actions when the event occurs.
You can bind sheet events using the bind and unbind methods for the sheet. You can also use the unbindAll method to unbind all the events. As with jQuery's bind and unbind, you can handle the sheet's bind and unbind, as shown in the following code:
var spread = GC.Spread.Sheets.findControl(document.getElementById('ss')); var sheet = spread.getActiveSheet(); var selectionChanged = GC.Spread.Sheets.Events.SelectionChanged; sheet.bind(selectionChanged, function(e,args) { // sheet event // do some thing... }); // remove the binding of an event on the sheet. sheet.unbind(selectionChanged); // removes the binding of all events on the sheet. sheet.unbindAll();
When you want to perform tasks that might trigger several events, and you don't want the sheet to trigger these events, use the suspendEvent method to keep the events from occurring. After the tasks are complete, you can use the resumeEvent method to resume triggering events, as shown in the following example:
var spread = GC.Spread.Sheets.findControl(document.getElementById('ss')); var sheet = spread.getActiveSheet(); sheet.suspendEvent(); //do some operation... sheet.resumeEvent();