Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Sync the horizontal scrolling of two instances in JavaScript

Background:

To sync the horizontal scrolling of two instances, we must set the displayed left column of one instance to be the other instances' horizontal position. Using the LeftColumnChanged event, we can then set the HorizontalPosition of the other instance so that both sheets will scroll horizontally at the same time.

Steps to Complete:

Bind the LeftColumnChanged event of one instance to the left HorizontalPosition of the other

Getting Started:

Bind the LeftColumnChanged event of one instance to the top HorizontalPosition of the other

var spread1 = new GC.Spread.Sheets.Workbook(document.getElementById("ss1"));
var sheet1 = spread1.getActiveSheet();

var spread2 = new GC.Spread.Sheets.Workbook(document.getElementById("ss2"));
var sheet2 = spread2.getActiveSheet();

sheet1.bind(GC.Spread.Sheets.Events.LeftColumnChanged, function(sender,args) {
  sheet2.showColumn(args.newLeftCol, GC.Spread.Sheets.HorizontalPosition.left);
});