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

Autoscroll grid to the bottom

2 Answers 886 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Clint Singer
Top achievements
Rank 1
Clint Singer asked on 13 Oct 2010, 01:10 AM
Hi,

I was wondering if there is a way to have the grid automatically scroll to the bottom when new items are added to the ObservableCollection that is bound to the ItemsSource.  Basically I want to ensure that the newest item is visible as it is added.

Cheers,
Clint

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 15 Oct 2010, 08:54 AM
Hi Clint Singer,

I have just created a how-to article on this topic. It will go live next week. Here is its content:

This article shows how to scroll RadGridView to a particular row and / or column.

We will use the ScrollIntoViewAsync method against a grid with many rows and columns.

The ScrollIntoViewAsync method accepts the following parameters:

  • DataItem of type Object - here you pass the business object you want to scroll to.
  • [optional] Column of type GridViewColumn - here you pass the GridViewColumn you want to scroll to
  • CallBack method - it will be called when the method succeeds

Here is the code that will scroll into the last row and last column of the gridview:


gridView.ScrollIntoViewAsync(this.gridView.Items[this.gridView.Items.Count - 1], //the row
         this.gridView.Columns[this.gridView.Columns.Count - 1], //the column
         new Action<FrameworkElement>((f) =>
               {
                    (f as GridViewRow).IsSelected = true; // the callback method
               }));

You should use this method when the virtualization is turned on (which is by default). If for some reason you have disabled the virtualization - you can use the ScrollIntoView counterpart. The only difference in terms of programming API is that no callback method is called when the ScrollIntoView succeeds.

Hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Clint Singer
Top achievements
Rank 1
answered on 19 Oct 2010, 07:36 PM
Hi,

Thanks for the sample.  I would like to make feature request to add an Autoscroll feature to the grid.  If Autoscroll is on then the grid will scroll to the bottom of the grid or new item.  When someone uses the scrollbar it disables the autoscroll feature until the scrollbar is scrolled to the bottom, reenabling the autoscroll.

Or some mechanism to support that type of scenario as I would think it is a fairly common requirement.

Cheers,
Clint
Tags
GridView
Asked by
Clint Singer
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Clint Singer
Top achievements
Rank 1
Share this question
or