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

Scroll to the new row after insert

2 Answers 349 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hakim
Top achievements
Rank 1
Hakim asked on 23 Sep 2011, 01:36 PM
Hi,

I have an issue about the scroll on my gridview.
My gridview contains a lot of data so there is vertical scrollbars and I set the insert row to visible.
The problem is when I enter data on the insert row and I press enter the gridview don't scroll to the the added row.
Here is my gridview:
<telerik:RadGridView telerik:StyleManager.Theme="Office_Blue"  Width="auto" Height="200"  x:Name="rgvTest"
    ItemsSource="{Binding TrckTest, IsAsync=True}"
    DataLoadMode="Asynchronous"
    SelectionMode="Extended"
    AutoGenerateColumns="False"
    ScrollMode="Deferred"
    EnableRowVirtualization="True"
    SnapsToDevicePixels="True"
    UseLayoutRounding="True"
    ActionOnLostFocus="None"
    ShowInsertRow="{Binding IsReadOnly}"
    CanUserInsertRows="{Binding IsReadOnly}"
    CanUserDeleteRows="{Binding IsReadOnly}"
    Grid.Column="0" RowEditEnded="rgvTest_RowEditEnded">
 
    <i:Interaction.Triggers>
    <i:EventTrigger EventName="RowEditEnded">
    <Commanding:EventToCommand Command="{Binding TestEditEndedCommand}" PassEventArgsToCommand="True"/>
    </i:EventTrigger>
 
    <i:EventTrigger EventName="AddingNewDataItem">
    <Commanding:EventToCommand Command="{Binding AddNewTestEvent}" PassEventArgsToCommand="True" />
    </i:EventTrigger>
 
    <i:EventTrigger EventName="SelectionChanged">
    <Commanding:EventToCommand Command="{Binding ItemTestSelectedCommand}" CommandParameter="{Binding ElementName=rgvTest, Mode=OneWay, Path=SelectedItem}"/>
    </i:EventTrigger>
    </i:Interaction.Triggers>
 
    <telerik:RadGridView.Columns>
    ...
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

I tried to use the event RowEditEnded in the code behind to scroll to the position of  the row like this but it didn't work:
private void rgvTest_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
        rgvTest.ScrollIntoView(e.Row);
}

Do you any solution about this issue?
Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 23 Sep 2011, 01:49 PM
Hello Hakim,

You can try the following:

private void clubsGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.Row is GridViewNewRow)
            {
                this.clubsGrid.SelectedItem = e.Row.Item;
                this.clubsGrid.ScrollIntoView(this.clubsGrid.SelectedItem);
            }
        }
 

Best wishes,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Hakim
Top achievements
Rank 1
answered on 26 Sep 2011, 09:01 AM
Thank you Maya it works great!
Tags
GridView
Asked by
Hakim
Top achievements
Rank 1
Answers by
Maya
Telerik team
Hakim
Top achievements
Rank 1
Share this question
or