Keep two ListGrids showing the same records

I’d like to be able to keep two ListGrids showing the same records. That is, scroll on one and the other scrolls. I don’t care too much if the control is bi-directional or if one ListGrid controls the other.

What I’m looking for is the API ListGrid.setDrawArea() - I don’t think it exists though. I had a peek at the ListGrid.js code to see how frozen rows do this, but no hints there.

This nearly works, but is not efficient. Is there a way to programmatically change the rendered area of the listGrid?

		final ListGrid listGrid1 = new ListGrid();
		final ListGrid listGrid2 = new ListGrid();
		listGrid1.setAutoFetchData(true);
		DataSource dummyData = getData();
		generate(dummyData, 1000);

		listGrid1.setDataSource(dummyData);
		listGrid2.setDataSource(dummyData);
		// listGrid2.setSav

		listGrid1.addDrawAreaChangedHandler(new DrawAreaChangedHandler() {
			@Override
			public void onDrawAreaChanged(DrawAreaChangedEvent event) {
				Integer[] drawArea = listGrid1.getDrawArea();
				int start = drawArea[0];
				int end = drawArea[1];				listGrid2.setData(listGrid1.getDataAsRecordList().getRange(
						start, end));
			}
		});

		HLayout hLayout = new HLayout();
		hLayout.addMember(listGrid1);
		hLayout.addMember(listGrid2);
		hLayout.setWidth100();
		hLayout.setHeight100();
		hLayout.draw();

ok. found it.

this could probably be improved by adding a redraw time delay.

can i ask though, how come frozen columns don’t use this method (or do they?). the listgrid.js code is cluttered with frozen logic.

		final ListGrid listGrid1 = new ListGrid();
		final ListGrid listGrid2 = new ListGrid();
		listGrid1.setAutoFetchData(true);
		listGrid2.setAutoFetchData(true);
		DataSource dummyData = getData();
		generate(dummyData, 1000);

		listGrid1.setDataSource(dummyData);
		listGrid2.setDataSource(dummyData);
		// listGrid2.setSav

		listGrid1.addDrawHandler(new DrawHandler() {
			@Override
			public void onDraw(DrawEvent event) {
				Scheduler.get().scheduleDeferred(new ScheduledCommand() {
					@Override
					public void execute() {
						final GridRenderer gridRenderer1 = listGrid1
								.getGridRenderer();
						final GridRenderer gridRenderer2 = listGrid2
								.getGridRenderer();
						gridRenderer1.addScrolledHandler(new ScrolledHandler() {
							@Override
							public void onScrolled(ScrolledEvent event) {
								int top = gridRenderer1.getScrollTop();
								int left = gridRenderer1.getScrollLeft();
								gridRenderer2.scrollTo(left, top);
							}
						});

					}
				});
			}
		});

		HLayout hLayout = new HLayout();
		hLayout.addMember(listGrid1);
		hLayout.addMember(listGrid2);
		hLayout.setWidth100();
		hLayout.setHeight100();
		hLayout.draw();