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 vertical scrolling of two Spread instances in JavaScript

Background:

To sync the vertical scrolling of two instances, we must set the displayed top row of one instance to be the other instances' vertical position. Using the TopRowChanged event, we can then set the VerticalPosition of the other instance so that both sheets will scroll vertically at the same time.

Steps to Complete:

Bind the TopRowChanged event of one instance to top VerticalPostion of the other

Getting Started:

Bind the TopRowChanged event of one instance to top VerticalPostion 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.TopRowChanged, function(sender, args) {
  	sheet2.showRow(args.newTopRow, GC.Spread.Sheets.VerticalPosition.top);
});