Hello,
I'm using WPF RadGridView which loades a large database table (about 200000 rows).
I bind the GridView to VirtualQueryableCollectionView object which makes async calls to WCF service in the ItemsLoading event.
The data from the WCF web service is, of course, retured after the VirtualQueryableCollectionView.ItemsLoading event is ended.
When the data is retured from the WCF web service I load the data to the VirtualQueryableCollectionView using the VirtualQueryableCollectionView.Load method.
The problem is when I drag the scroller, for example, to the middle of the grid it doens't show the loaded data, because the data is loaded a little later after the VirtualQueryableCollectionView.ItemsLoading is finished.
When I scroll to other point in the grid and return back to that place, the data which was loaded earliear is shown correctly.
It seems like it needs to send some notify to the GUI that the data is loaded after the VirtualQueryableCollectionView.ItemsLoading is finished (like INotifyPropertyChanged interface or something).
BTW, when I use sync WCF web service, it works correctly because the data is loaded within the VirtualQueryableCollectionView.ItemsLoading event.
How can I resolve this problem?
Thanks,
Alex Vr.
I'm using WPF RadGridView which loades a large database table (about 200000 rows).
I bind the GridView to VirtualQueryableCollectionView object which makes async calls to WCF service in the ItemsLoading event.
The data from the WCF web service is, of course, retured after the VirtualQueryableCollectionView.ItemsLoading event is ended.
When the data is retured from the WCF web service I load the data to the VirtualQueryableCollectionView using the VirtualQueryableCollectionView.Load method.
The problem is when I drag the scroller, for example, to the middle of the grid it doens't show the loaded data, because the data is loaded a little later after the VirtualQueryableCollectionView.ItemsLoading is finished.
When I scroll to other point in the grid and return back to that place, the data which was loaded earliear is shown correctly.
It seems like it needs to send some notify to the GUI that the data is loaded after the VirtualQueryableCollectionView.ItemsLoading is finished (like INotifyPropertyChanged interface or something).
BTW, when I use sync WCF web service, it works correctly because the data is loaded within the VirtualQueryableCollectionView.ItemsLoading event.
How can I resolve this problem?
Thanks,
Alex Vr.
7 Answers, 1 is accepted
0
Alex Vr
Top achievements
Rank 1
answered on 22 Jun 2011, 07:05 AM
Hello,
Is there some solution to this problem?
Regards,
Alex Vr.
Is there some solution to this problem?
Regards,
Alex Vr.
0
Alex Vr
Top achievements
Rank 1
answered on 22 Jun 2011, 08:23 AM
I checked the following example: http://www.telerik.com/ClientsFiles/279613_DataVirtualization.zip
It is attached to this post: http://www.telerik.com/community/forums/wpf/gridview/gridview-with-custom-virtualization.aspx.
The same problem exists in that example, when I scroll fast to the middle of the grid, the data is loaded but not shown in the grid.
To see the problem more clearly, I added Thread.Sleep(1000) to ItemsLoading Event:
Can someone advise how to resolve this? Maybe it is a BUG?
BTW, sync loading works correctly, the problem is only with async loading.
I checked to following code which loades the data in sync way and it works.. but I need async loading.
Thanks,
Alex Vr.
It is attached to this post: http://www.telerik.com/community/forums/wpf/gridview/gridview-with-custom-virtualization.aspx.
The same problem exists in that example, when I scroll fast to the middle of the grid, the data is loaded but not shown in the grid.
To see the problem more clearly, I added Thread.Sleep(1000) to ItemsLoading Event:
var view =
new
VirtualQueryableCollectionView<Customer>() { LoadSize = pageSize, VirtualItemCount = customerProvider.FetchCount() };
view.ItemsLoading += (s, args) =>
{
new
Thread(() =>
{
Thread.Sleep(1000);
view.Load(args.StartIndex, customerProvider.FetchRange(args.StartIndex, args.ItemCount));
}).Start();
};
DataContext = view;
Can someone advise how to resolve this? Maybe it is a BUG?
BTW, sync loading works correctly, the problem is only with async loading.
I checked to following code which loades the data in sync way and it works.. but I need async loading.
var view =
new
VirtualQueryableCollectionView<Customer>() { LoadSize = pageSize, VirtualItemCount = customerProvider.FetchCount() };
view.ItemsLoading += (s, args) =>
{
view.Load(args.StartIndex, customerProvider.FetchRange(args.StartIndex, args.ItemCount));
};
DataContext = view;
Thanks,
Alex Vr.
0
Hi Alex Vr,
The behavior that you have described is expected. Whenever you use asynchronous data loading mechanism, data will be available after you have scrolled and that is why you see empty rows.
Once the data is available (usually after scrolling) it is loaded into the grid and the empty rows are filled.
Greetings,
Milan
the Telerik team
The behavior that you have described is expected. Whenever you use asynchronous data loading mechanism, data will be available after you have scrolled and that is why you see empty rows.
Once the data is available (usually after scrolling) it is loaded into the grid and the empty rows are filled.
Greetings,
Milan
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
Alex Vr
Top achievements
Rank 1
answered on 22 Jun 2011, 09:08 AM
Hi Milan,
Thanks for the answer, but this is not the case, I know that it takes time to load the data and it shows blank rows during the loading time. It works correctly.
But problem is specific: Only when you move the scroller to some "far" point (FE: middle of the grid) and never move the scroller again it never shows the rows (even though the data was already loaded in VirtualQueryableCollectionView)
* It hapens more clearly when the async load is slow.
The grid shows these rows only when I scroll to some other place in the grid and then return.
It seems like it just doens't refresh the grid view or the grid doesn't handle notify changes correctly.
Please see the example + change. You'll see that when you move the scroll bar to some point (and then not move the scroller at all) the data will never be shown in the grid even though the data was already loaded from the async data return.
When you'll move the scroll to some other place (and then return) or move the wheel on the mouse you'll see the data.
Hope I explained it correctly.
Sorry for my bad English.
Thanks,
Alex Vr.
Thanks for the answer, but this is not the case, I know that it takes time to load the data and it shows blank rows during the loading time. It works correctly.
But problem is specific: Only when you move the scroller to some "far" point (FE: middle of the grid) and never move the scroller again it never shows the rows (even though the data was already loaded in VirtualQueryableCollectionView)
* It hapens more clearly when the async load is slow.
The grid shows these rows only when I scroll to some other place in the grid and then return.
It seems like it just doens't refresh the grid view or the grid doesn't handle notify changes correctly.
Please see the example + change. You'll see that when you move the scroll bar to some point (and then not move the scroller at all) the data will never be shown in the grid even though the data was already loaded from the async data return.
When you'll move the scroll to some other place (and then return) or move the wheel on the mouse you'll see the data.
Hope I explained it correctly.
Sorry for my bad English.
Thanks,
Alex Vr.
0
Alex Vr
Top achievements
Rank 1
answered on 22 Jun 2011, 12:23 PM
Hello,
I think I faund the problem with the VirtualQueryableCollectionView.
The problem is that after the VirtualQueryableCollectionView.ItemsLoading event is fired, it waits for the VirtualQueryableCollectionView.Load method to be executed before it can fire again.
So when we scroll the grid faster than it loads the data, the VirtualQueryableCollectionView.ItemsLoading is not fired for the last data.
Another issue that is problematic is when an error accours in the WCF web service and it can't load some data for some reason (the VirtualQueryableCollectionView.Load method will not be called). In this case the grid will never fetch data again and the VirtualQueryableCollectionView.ItemsLoading event will never fire again. So we'll not be able to load data to the gird anymore.
I think it is a BUG, becuase the event should not wait for Loading objects from the previous calls. In this case it misses event fires (Especially when the async call are long) and because of that part of the data is not loaded at all. Finally it causes blank rows to be seen on the grid that will not be loaded with data.
Regards,
Alex Vr.
I think I faund the problem with the VirtualQueryableCollectionView.
The problem is that after the VirtualQueryableCollectionView.ItemsLoading event is fired, it waits for the VirtualQueryableCollectionView.Load method to be executed before it can fire again.
So when we scroll the grid faster than it loads the data, the VirtualQueryableCollectionView.ItemsLoading is not fired for the last data.
Another issue that is problematic is when an error accours in the WCF web service and it can't load some data for some reason (the VirtualQueryableCollectionView.Load method will not be called). In this case the grid will never fetch data again and the VirtualQueryableCollectionView.ItemsLoading event will never fire again. So we'll not be able to load data to the gird anymore.
I think it is a BUG, becuase the event should not wait for Loading objects from the previous calls. In this case it misses event fires (Especially when the async call are long) and because of that part of the data is not loaded at all. Finally it causes blank rows to be seen on the grid that will not be loaded with data.
Regards,
Alex Vr.
0
Diller
Top achievements
Rank 1
answered on 24 Aug 2011, 03:37 PM
Hello
I have also noticed this issue and it's a little annoying. I'm also loading data in another thread with setting IsBusy to true in the grid.
There is no problem when data is scrolled with scroll bar by using buttons or paging but occurs when scroll button is dragged very fast.
When the ItemsLoading event is fired scroll bar is further than e.StartIndex reports it and is not fired any more.
For example loaded are data from StartIndex=20000 and should be from StartIndex=50000. When data are set with Load function empty rows are shown because actually expected data are not loaded.
After few days of war with this I finally found solution. Maybe it's not excellent but it's effective.
DataLoaded function is called after data are ready to set.
Data are loaded in all cases, even if scroll bar is much further than first call to ItemsLoading event.
I hope this part of code will be helpfull.
Greetings,
Jarosław Koper
I have also noticed this issue and it's a little annoying. I'm also loading data in another thread with setting IsBusy to true in the grid.
There is no problem when data is scrolled with scroll bar by using buttons or paging but occurs when scroll button is dragged very fast.
When the ItemsLoading event is fired scroll bar is further than e.StartIndex reports it and is not fired any more.
For example loaded are data from StartIndex=20000 and should be from StartIndex=50000. When data are set with Load function empty rows are shown because actually expected data are not loaded.
After few days of war with this I finally found solution. Maybe it's not excellent but it's effective.
private
delegate
void
DataLoadedDelegate(
int
startIndex, EnumerableRowCollection<DataRow> data);
private
VirtualQueryableCollectionView GridVirtualCollectionView {
get
;
set
; }
private
bool
VirtualCollectionViewRefreshNeeded {
get
;
set
; }
/// <summary>
/// Handling virtual data collection loading event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
GridVirtualCollectionView_ItemsLoading(
object
sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
var verticalScrollBar =
grid.ChildrenOfType<ScrollBar>().Where(s => s.Orientation == Orientation.Vertical).FirstOrDefault();
if
(verticalScrollBar !=
null
)
//Set grid vertical scrollbar event
verticalScrollBar.Scroll += GridVerticalScrollBar_Scroll;
grid.IsBusy =
true
;
//Start thread that is loading data asynchronously
new
LoadDataThread(
this
, e.StartIndex, e.ItemCount);
}
/// <summary>
/// Handle grid vertical scrollbar event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
GridVerticalScrollBar_Scroll(
object
sender, ScrollEventArgs e)
{
VirtualCollectionViewRefreshNeeded =
true
;
}
private
void
DataLoaded(
int
startIndex, EnumerableRowCollection<DataRow> data)
{
if
(Dispatcher.Thread != Thread.CurrentThread)
Dispatcher.Invoke(
new
DataLoadedDelegate(DataLoaded),
new
object
[] { startIndex, data });
else
{
VirtualCollectionView.Load(startIndex, data);
//Refreshing virtual collection if it's needed
if
(VirtualCollectionViewRefreshNeeded)
{
VirtualCollectionViewRefreshNeeded =
false
;
VirtualCollectionView.Refresh();
return
;
}
grid.IsBusy =
false
;
}
}
DataLoaded function is called after data are ready to set.
Data are loaded in all cases, even if scroll bar is much further than first call to ItemsLoading event.
I hope this part of code will be helpfull.
Greetings,
Jarosław Koper
0
Rolf
Top achievements
Rank 2
answered on 16 May 2012, 09:26 AM
I'm having kind of the same behaviour in the latest version.
If I only have a few lines (no scroll bar) and if I select a row and show its details template. After adding another row (in another form) and doing refresh on the grid the last row is added but not loaded. This behaviour is there around half of the times.
If I dont select a details template before doing refresh this does not occur.
If I have enough lines for a vertical scroll bar the last row is loaded when I scroll down to it.
If I only have a few lines (no scroll bar) and if I select a row and show its details template. After adding another row (in another form) and doing refresh on the grid the last row is added but not loaded. This behaviour is there around half of the times.
If I dont select a details template before doing refresh this does not occur.
If I have enough lines for a vertical scroll bar the last row is loaded when I scroll down to it.