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

Vertical Scrollbar Position

8 Answers 399 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramin
Top achievements
Rank 1
Ramin asked on 28 Dec 2010, 11:27 PM
Hi,
I have a GridView that I need to add some row whenever user reaches to the bottom of the Grid by scrolling down. I couldn't find any event that fires when this happens. I have used PreviewKeyDown but I cannot know if the vertical scrollbar is at the bottom and cannot move further down so I can add more rows to the Grid.
Thanks,

8 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Dec 2010, 07:46 AM
Hi,

 If you want to load records on demand while scrolling you can use our VirtualQueryableCollectionView. More info can be found on these links:

http://blogs.telerik.com/vladimirenchev/posts/10-10-20/data_virtualization_for_your_silverlight_and_wpf_applications.aspx

http://blogs.telerik.com/vladimirenchev/posts/10-12-09/server_sorting_and_filtering_with_wcf_ria_services_and_telerik_data_virtualization_for_silverlight.aspx 

http://www.telerik.com/help/wpf/using-data-virtualization.html

Here is the Silverlight version of our demos - WPF version is similar:
http://demos.telerik.com/silverlight/#DataVirtualization/FirstLook

Regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Wesley Witt
Top achievements
Rank 1
answered on 05 Jan 2011, 10:41 PM
I would like to better understand the interaction between the VirtualQueryableCollectionView as a data context and the grid view.  In looking at the implementation of the VirtualQueryableCollectionView I can see that it inherits from QueryableCollectionView and implements IList, ICollection and IEnumerable.  I would have expected the class to implement another interface to support the virtualization.  Instead I see a property named
VirtualItemCount as well as other members to support virtualization.

I have my own collection view that implements IPagedCollectionView, etc. but I would like to enable the virtual scroll bar so that the user can see and interact with a vertical scroll bar.  What exactly do I need to implement?  Without the benefit of an interface how does the grid view control discover that the data context supports virtualization?  I see that by assigning an instance of a VirtualQueryableCollectionView to the data context enables this and I would like to know what part of the VirtualQueryableCollectionView I need to implement to make this work.

-Wes
0
Vlad
Telerik team
answered on 06 Jan 2011, 08:08 AM
Hi,

 You do not need to implement anything. Just retrieve desired records in ItemsLoading event from your own IPagedCollectionView. You need also to set VirtualItemCount and LoadSize.

More info can be found on the links I've posted in the previous reply.  

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Wesley Witt
Top achievements
Rank 1
answered on 06 Jan 2011, 05:54 PM
Thanks.  I found that using VirtualQueryableCollectionView is the best solution.  I get the virtualization and it seems to work well.

I do have a few issues with VirtualQueryableCollectionView that you could help me with.

First, I need keyboard support and the grid control does not seem to have this so I'm having to implement it myself.  I would like to request that you guys add keyboard support to the control.  In the mean time I need to make this work.  The problem that I'm running into is related to focus.  I have the keyboard events all working, but the code that processes the keyboard events need to reposition the grid and then set focus to the proper row and cell in the grid.  To do this it seems that I need access to the rows collection, but I cannot find any way to get access.  There is an items collections, but that is simply a collection of the objects in the grid.  I need to access the actual row objects to that I can affect the focus.  What is your guidance on this?

Second, I have a question regarding performance of the VirtualQueryableCollectionView.  It seems that the VirtualQueryableCollectionView pages in the data as needed based on the user's scrolling of the control.  This is good, but it doesn't seem to maintain a window into the virtual data set and throw out data that is outside that window.  This means that if the user scrolls completely through all of the records the VirtualQueryableCollectionView will have every record in memory.  Is this a correct understanding of how this works?

-Wes
0
Wesley Witt
Top achievements
Rank 1
answered on 07 Jan 2011, 01:21 AM
In terms of the scrolling I have found that I can use ScrollIntoViewAsync to do what I need when responding to the keyboard event.  In the asynch handler for the ScrollIntoViewAsync I can select and set focus to the row.  This is great and I only have one remaining problem.  That is when to do it.  I was doing it when the data was loaded but that only solves the case when new data are paged in.  If you're scrolling through data that has already been read then you're out of luck.  So in looking at all the events available to me on the grid view controller it seemed like I could use the RowLoaded event.  I am seeing a problem with this event in that the grid is loading data into the control before it is displayed.  I can see in the debugger that the RowLoaded event is triggered for data before it is displayed.  So if I use ScrollIntoViewAsync in the RowLoaded handler it will cause the entire data set to be read in and paged through.  Is there a property on the grid view that can change this behavior?
0
Vlad
Telerik team
answered on 07 Jan 2011, 08:42 AM
Hi,

 RowLoaded is related to the load of the UI element which will try to access the data item associated with this row index which will invoke the load of the virtual collection. 

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Wesley Witt
Top achievements
Rank 1
answered on 07 Jan 2011, 04:54 PM
Thanks, I'm aware of what RowLoaded does.  My point is that the control is loading rows before they are actually visible to the user.  Also the IsVisible property is set to true when in fact the row is not visible.  This seems like a bug, unless there is some way to control the behavior.  Can you explain this?

Also, can you address my question about performance?
0
Vlad
Telerik team
answered on 11 Jan 2011, 11:11 AM
Hi,

Indeed the virtual collection will create internally collection with total count empty items (null) and will replace this null item with the original when loaded. If you have 15 rows visible in the grid and 10 for LoadSize you will get two requests and finally the collection will load 20 items.

I'm not sure about the IsVisible issue - can you clarify?

Regards,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Ramin
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Wesley Witt
Top achievements
Rank 1
Share this question
or