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

ScrollIntoView issu

3 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kennet
Top achievements
Rank 2
Kennet asked on 14 Jan 2010, 02:13 PM
Here is the senario.

I have a ObservableCollection with let say 100 items.  I have clicked on and selected row # 60.  Then I delete row 50 to 100, and instantly add 50 new rows (I have now 100 items again. The grid "auto updates" as the type of collection, But I loose my selection.

I can get what row that was selected before my update, and select it agan. But now that row is at the top of the grid. I want the selection to be at the same place as before update.

How can I scroll the grid to that same position?

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 14 Jan 2010, 02:50 PM
Hello Kennet,

If the requirement is to return to exactly the same position and you have equal number of items , you may try the following apporach :

befor the update - remember the current scroll position :


using Telerik.Windows.Controls;
...
...
...
  
 GridViewScrollViewer scroller = this.GridView.ChildrenOfType<GridViewScrollViewer>()[0];
            double cachedVerticalOffset = scroller.VerticalOffset;

after the data update - restore the scroll position to the cached one :

scroller.ScrollToVerticalOffset(cachedScrollOffset);



Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kennet
Top achievements
Rank 2
answered on 14 Jan 2010, 02:59 PM
Thanks Pavel,

But "ChildrenOfType" give me an error:

'Telerik.Windows.Controls.RadGridView' does not contain a definition for 'ChildrenOfType' and no extension method 'ChildrenOfType' accepting a first argument of type 'Telerik.Windows.Controls.RadGridView' could be found (are you missing a using directive or an assembly reference?)

I have version 2009.3.1219.35

0
Accepted
Vlad
Telerik team
answered on 14 Jan 2010, 03:01 PM
Hello Kennet,

ChildrenOfType is extension method available in Telerik.Windows.Controls namespace - you need to add:

using Telerik.Windows.Controls;

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Kennet
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Kennet
Top achievements
Rank 2
Vlad
Telerik team
Share this question
or