This is a migrated thread and some comments may be shown as answers.

RadSpreadsheet's vertical scrollbar is paging down by a single row at a time

2 Answers 197 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Sandra
Top achievements
Rank 1
Sandra asked on 09 Feb 2015, 04:17 PM
I've been trying out the RadSpreadsheet control in a small test application and am seeing some odd scrolling behavior, even within the provided samples.  (I'm using the 2014 Q3 version:  2014.3.1202.45.)

When there are enough rows in the viewable area to make paging up or down possible (for example, the viewport shows 20 rows and the spreadsheet holds 100 rows), clicking on the scrollbar background only moves the contents up or down by a single row.

I've attached an event handler to the sheet's ScrollBarsProvider.VerticalScrollBar.Scroll event, and I'm observing that the ScrollEventType is indeed LargeIncrement as expected, and the eventArgs.NewValue contents appear to be an expected large value.... however, the position within the sheet only moves by a single row.  This occurs within unmodified projects within the Telerik's xaml-sdk repository found on GitHub: https://github.com/telerik/xaml-sdk

What is going on with the scrolling?  What can I do to make the vertical scrollbar behave as expected?

(Also, I just noticed the horizontal scrollbar is behaving in the same way - only scrolling by a single column at a time.)

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Demirev
Telerik team
answered on 10 Feb 2015, 11:29 AM
Hi Sandra,

Internally the RadSpreadsheet handles the SmallIncrement and LargeIncrement both in the same way. This is the reason why it scrolls just one cell at a time.

I have prepared a sample code which you could use to workaround the behavior of the RadSpreadsheet. It handles only for vertical scrolling and the LargeIncrement, but you could easily modify it so it work for LargeDecrement and horizontal scrolling too:
private double verticalOffset;
 
public MainWindow()
{
    InitializeComponent();
 
    this.Loaded += this.MainWindow_Loaded;
    this.Unloaded += this.MainWindow_Unloaded;
}
 
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    this.radSpreadsheet.VerticalScrollBar.Scroll += this.VerticalScrollBar_Scroll;
    this.verticalOffset = this.radSpreadsheet.VerticalScrollBar.Value;
}
 
private void MainWindow_Unloaded(object sender, RoutedEventArgs e)
{
    this.radSpreadsheet.VerticalScrollBar.Scroll -= this.VerticalScrollBar_Scroll;
}
 
private void VerticalScrollBar_Scroll(object sender, ScrollEventArgs e)
{
    Worksheet worksheet = this.radSpreadsheet.ActiveWorksheet;
    ViewportPane viewportPane = this.radSpreadsheet.ActiveWorksheetEditor.SheetViewport[ViewportPaneType.Scrollable];
    CellRange scrollablePaneVisibleRange = viewportPane.VisibleRange;
    int topRowIndex = scrollablePaneVisibleRange.FromIndex.RowIndex;
    double currentOffset = e.NewValue;
    double delta = Math.Abs(currentOffset - this.verticalOffset);
 
    int newRowIndex = topRowIndex;
    if (e.ScrollEventType == ScrollEventType.LargeIncrement)
    {
        double rowHeights = viewportPane.Rect.Top;
        while (rowHeights < delta)
        {
            rowHeights += worksheet.Rows[newRowIndex].GetHeight().Value.Value;
            newRowIndex++;
        }
 
        this.radSpreadsheet.SetVerticalOffset(rowHeights);
    }
}

I have created a public item for your request in our feedback portal, where you can vote and subscribe in order to receive updates on the matter.

Regards,
Nikolay Demirev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sandra
Top achievements
Rank 1
answered on 10 Feb 2015, 05:05 PM
Nikolay - thanks for the response!  I've adapted the code to work in my test application, and it solves the problem.

A couple of comments (if anyone else sees this behavior): - I had to attach/detach the scroll event handlers in the RadSpreadsheet object's Loaded and Unloaded events, because in my case the RadSpreadsheet is initially hidden - the VerticalScrollBar / HorizontalScrollBar properties are null when the window is loaded.

Also modified the workaround code to handle scrolling up as well as down (check for ScrollEventType.LargeDecrement also).
Tags
Spreadsheet
Asked by
Sandra
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Sandra
Top achievements
Rank 1
Share this question
or