Completed
Last Updated: 08 Aug 2013 05:03 by ADMIN
ADMIN
Georgi I. Georgiev
Created on: 08 Aug 2013 05:03
Category: GridView
Type: Bug Report
0
FIX. RadGridView - ArgumentOutOfRangeException when panning up and down on touch device
To reproduce: Create a project with RadGridView, add some rows, make sure you have space to perform panning. Pan up and down, exception should occur. Workaround :

radgridView1.ViewDefinition = new MyTableViewDefinition();

public class MyTableViewDefinition : TableViewDefinition
{
    public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
    {
        return new MyGridTableElement();
    }
}

public class MyGridTableElement : GridTableElement
{
    protected override void OnPanGesture(Telerik.WinControls.PanGestureEventArgs args)
    {

        //base.OnPanGesture(args) -> you can stop touch support by also not calling the base and leaving this method empty
        if (args.IsBegin &&
             (this.RowScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) ||
             this.ColumnScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) ||
             this.ViewElement.TopPinnedRows.ControlBoundingRectangle.Contains(args.Location)))
        {
            return;
        }

        bool containsCurrent = (this.GridViewElement.CurrentRow == null && this.GridViewElement.Template == this.ViewTemplate);
        if (!containsCurrent)
        {
            foreach (IRowView child in this.GridViewElement.GetRowViews(this.GridViewElement.CurrentRow.ViewInfo))
            {
                containsCurrent |= (child == this);
            }
        }

        if (!containsCurrent)
        {
            return;
        }

        this.GridViewElement.EndEdit();
        int newVerticalValue = this.RowScroller.Scrollbar.Value - args.Offset.Height;

        if (newVerticalValue > this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1)
        {
            newVerticalValue = this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1;
        }
        if (newVerticalValue < this.RowScroller.Scrollbar.Minimum)
        {
            newVerticalValue = this.RowScroller.Scrollbar.Minimum;
        }

        RadScrollBarElement rowScrollbar = this.RowScroller.Scrollbar;
        if (newVerticalValue > rowScrollbar.Maximum)
        {
            newVerticalValue = rowScrollbar.Maximum;
        }
        else if (newVerticalValue < 0)
        {
            newVerticalValue = 0;
        }

        this.RowScroller.Scrollbar.Value = newVerticalValue;

        int newHorizontalValue = this.ColumnScroller.Scrollbar.Value - args.Offset.Width;
        if (newHorizontalValue > this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1)
        {
            newHorizontalValue = this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1;
        }
        if (newHorizontalValue < this.ColumnScroller.Scrollbar.Minimum)
        {
            newHorizontalValue = this.ColumnScroller.Scrollbar.Minimum;
        }

        RadScrollBarElement columnScrollBar = this.ColumnScroller.Scrollbar;
        if (newHorizontalValue > columnScrollBar.Maximum)
        {
            newHorizontalValue = columnScrollBar.Maximum;
        }
        else if (newHorizontalValue < 0)
        {
            newHorizontalValue = 0;
        }

        this.ColumnScroller.Scrollbar.Value = newHorizontalValue;
        args.Handled = true;
    }
}
0 comments