I have an issue when I try using your IsBusy property inside a grid.
Happens that the panel won't disappear. I tried using several of those "Loaded" events to make it happen manually (grid.IsBusy = false;), but then it won't even show at all.
I am using virtualization and infinite scrolling in my grid.
I just need a solution to hide the spinner when the data finish loading.
here is my code:
ViewModel.cs *(install Fody.PropertyChanged nugget to make have it compiling)
24 Answers, 1 is accepted
The correct approach in this scenario would be to set RadGridView's IsBusy property to True and then return it to False in the GridView's DataLoaded event.
Please let me know if this answers your question. Don't hesitate to contact us again should any further questions or concerns arise.
If I use that code, the spinner won't show at all.
please try to reproduce my scenario on your side, you have my code
I did try to reproduce your scenario, but the behavior I get is expected. The reason the BusyIndicator is not shown is that RadGridView loads the items instantaneously. To simulate the loading of items, I've added a 2-second delay. You can see that once the items are actually loaded, the indicator is hidden.
I'm attaching a modified version of your project to my reply. Please let me know if I've missed something important.
but if I modify your sample and remove that timer, the list will take some time to load (cos its 1 million rows), but wont show the spinner...
can you try that scenario?
I've modified my sample project and attached it to my reply. It makes use of the ItemsLoading and ItemsLoaded events of the VirtualQueryableCollectionView and displays the IsBusyIndicator when necessary. Please note that with this approach, the IsBusyIndicator will be shown each time the ItemsLoading is called.
Could you please have a look at the attached project and let me know if this approach would work for you?
I would also like to ask - is there a specific reason you're using a VirtualQueryableCollectionView? If that is not the case, maybe I can offer another solution based on your specific requirements.
Yes there is:
I followed your documentations regarding an endless scrolling (virtualization load) method. because your pagination via RadPageControl is broken when we apply the filter on the grid.
the endless scrolling works really fine with the filter and everything
I will give your solution a try and return in a minute
It is WORKING!!!
Thank you once more
There is just one detail that is missing:
the spinner doesn't "spin"
it only shows there, without animation.
Such behavior would be expected, as both the animation and the data loading are executed on the UI thread. You need to move the time consuming operation on a separate thread. This can be achieved by using a Background Worker. You may also find the How to use WPF Background Worker StackOverflow thread useful.
Hope this helps.
The logic of the backgroundworker is reasonable to solve this problem. but it won't match with Dilyan Traykov last solution.
because it needs to use the fully initialized View (list) and set the View_ItemsLoading and View_ItemsLoaded events upon it
when I use the BackgroundWorker, it will simply throw me a null exception
I will need a little more time to search for a solution for your scenario, but I will get back to you as soon as possible.
Thank you very much Dilyan.
I will be looking forward to hear from you
Thank you for your patience.
Another approach I can suggest is to wrap your RadGridView in a RadBusyIndicator with a DisplayAfter property set to 0 and then set its (rather than RadGridView's) IsBusy property in the ItemsLoading and ItemsLoaded events:
Please let me know if you're satisfied with the result from this approach.
Thank you very much!
I must retract what I have just said.
The solution (actually both of them) fails when grouping.
But it will still do for now. But please verify that further on...
I might need to come back to this ticket later
In order to group the items correctly, the VirtualQueryableCollectionView needs to load all the items beforehand and the ItemsLoading and ItemsLoaded events do not get fired.
Please let me know if this clarifies things for you.
Yes it does. And it also explains why the performance is not the best when grouping...
So there is no way of using a IsBusy indicator for the case?
I tried handling the Grouping and Grouped events, for no use
If you want to display the BusyIndicator when grouping and expanding the groups, you can use the following event handlers, which seem to be working fine at my end:
I've attached a modified version of my sample project to demonstrate this. Could you verify that you're using the same approach?
I wish I could give you good news, but I used your sample and I couldn't get it to run.
but as I noticed it approaches a slight different scenario, I decided to change is slightly to run it and get closer to my scenario:
Here is what I changed:
And I added a Lint to SQL (dbml) file containing only one table (1 million rows on it. each with a random name and some random columns)
This is it. And the grouping won't show the Spinner.
I'm reattaching the modified project. At my end, it successfully displays the BusyIndicator once I group the items. Could you please have a look and let me know how this goes at your end?
sorry but your sample doesn't reflect my scenario.
My last post shows how to do so.
- linq to sql
- 1 million rows
I have modified my project accordingly, but everything is still working as expected. Could you please modify the attached project or maybe send over a sample project of your own that demonstrates the behavior you're observing at your end?
Thank you in advance for your cooperation on the matter.
As per your request, I've prepared a small sample project demonstrating how to bind the IsBusy property of the control to a property in your viewmodel and use this property to display the indicator while the data is loading.
Please have a look and let me know if you find this example helpful.