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

ScrollIntoView issue

4 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sum sum
Top achievements
Rank 1
sum sum asked on 05 Nov 2009, 09:31 PM
Hi,

It seems I can never get ScrollIntoView work. I got an error when I do:

if (grid.SelectedItem !=null)
    grid.ScrollIntoView(grid.SelectedItem);

Did I miss anything?

Thanks,

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 06 Nov 2009, 06:34 AM
Hi,

I've just tried this however everything worked fine - you can check the attached project for more info.

Kind regards,
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.
0
sum sum
Top achievements
Rank 1
answered on 06 Nov 2009, 03:00 PM
Hi,

There are two issues here.

1. In your sample, it is working. However, in my application although the grid.ItemSource has something but grid.items.count is always = 0 until the UI is rendered. Then the next time grid.Items.count has something and I can ScrollIntoView. I am not sure if it is a bug. Once you specify the ItemSource, does the items.count has a value right away?

2. When items.count !=0, when doing ScrollIntoVIew, the error I got is:

"Object reference not set to an instance of an object."

at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)\r\n   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertNewContainer(Int32 childIndex, UIElement container)\r\n   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized)\r\n   at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.BringIndexIntoView(Int32 index)\r\n   at Telerik.Windows.Controls.GridView.GridViewDataControl.ScrollRowIntoView(Object item)\r\n   at Telerik.Windows.Controls.GridView.GridViewDataControl.ScrollIntoView(Object item)\r\n  
0
sum sum
Top achievements
Rank 1
answered on 06 Nov 2009, 04:00 PM
In your sample, the data is pre-populated and then you scrollintoview.

But in my application:
let's say I have 10 records in the collection which is binding to the grid. I added one more record to the collection. grid.items.count turns to 11. SelectedItem goes to the newly added one. Then I tried to scrollIntoView this newly added record. It gave me the above error message. It seems although the grid recognize the newly added record, the ScrollIntoView does not know this item.
0
Milan
Telerik team
answered on 10 Nov 2009, 07:59 AM
Hi sum sum,

Please refer to this thread for more information.


Kind regards,
Milan
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
sum sum
Top achievements
Rank 1
Answers by
Vlad
Telerik team
sum sum
Top achievements
Rank 1
Milan
Telerik team
Share this question
or