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

[Solved] Scrollbar position effects speed of xRadDataGrid.Items.Refresh();

3 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 1
Patrick asked on 16 Sep 2010, 06:06 PM
Hello,

I'm using the RadGridView with a pager and I'm running a bit of code that takes significantly longer if the scroll bar is set to a position anywhere else other than full left. I only have 10 columns or so (15 Rows). I've narrowed it down and these lines take about 1 second each with the scroll bar not set full left.
xRadDataPager.Source = _mysource;
xRadDataPager.PageIndex = _pageindex;
xRadDataGrid.Items.Refresh();

With the scrollbar on the grid full left they are practically instant. I run them many times so the total operation goes from 1-2 seconds to 30-60 seconds or even minutes if there are many pages.

My xaml for the grid and pager are as such:
<telerikGridView:RadGridView x:Name="xRadDataGrid" Visibility="Collapsed" FontSize="14" ItemsSource="{Binding PagedSource,ElementName=xRadDataPager}" 
                             Height="455" HorizontalAlignment="Stretch" AutoGenerateColumns="False" 
                             Grid.Row="2" ShowGroupPanel="True" VerticalAlignment="Top" ElementExporting="mygrid_ElementExporting" IsReadOnly="True"
                             GotFocus="xRadData_GotFocus" MouseRightButtonUp="xRadDataGrid_MouseRightButtonUp"
                             Sorting="gridPlayerStats_Sorting" EnableColumnVirtualization="False"/>
<telerikControlsData:RadDataPager x:Name="xRadDataPager" Visibility="Collapsed" Grid.Row="3" FontSize="14" PageSize="15" 
                            DisplayMode="First, Last, Next, Previous, Text" IsTotalItemCountFixed="True" 
                            Foreground="White" Background="Black" Width="Auto" GotFocus="xRadData_GotFocus"/>
Setting the EnableColumnVirtualization to True doesn't help or affect the speed. I've tried programactically setting the scrollbar left before running my code as a hack (which I'm ok with if it works) with

xRadDataGrid.ScrollIntoView(xRadDataGrid.CurrentItem, xRadDataGrid.Columns[0]); but this doesn't seem to help, it appears as if the grid doesn't actally move the scrollbar until after my code has run.


Any ideas? Thank you,
Patrick

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 20 Sep 2010, 08:15 AM
Hello Patrick,

We would appreciate it if you could give us a little bit more information about your scenario. For example, when is the code problematic code executed? Are you refreshing the Items property on some event? Why do you need to call Items.Refresh?


Sincerely yours,
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
Patrick
Top achievements
Rank 1
answered on 20 Sep 2010, 05:28 PM
Hello Milan,
 
Well I was trying to get a hold of all the items currently in the grid that aren't filtered out and I wanted them in their sorted order (so the pager source wouldn't work). I was manually updating the pager then getting the next page of items from the grid, that why I needed to call Items.Refresh(), otherwise the grid items didn't reflect the page change.

I just found a better way that cuts the time down to a maximum of 6 seconds, which is great for what I need. I found that putting all the items on page 1 temporarily allows me to get a handle of those items. So I did this:

 

int pageSize = xRadDataGrid.Items.PageSize;
xRadDataGrid.Items.PageSize = xRadDataGrid.Items.TotalItemCount;
  
//Running code on xRadDataGrid.Items here...
xRadDataGrid.Items.PageSize = pageSize;

It is still slower depending on the location of the scrollbar, full left scrollbar is 1.5 seconds, but again a max of 6 seconds to run this instead of possibly minutes. Is there another way to get a handle on the collection of the grid with filtering and sorting respected other than what I did above? Thanks

-Patrick
0
Milan
Telerik team
answered on 21 Sep 2010, 10:34 AM
Hi Patrick,

There is another way to get this list without manipulating the PageSize property. you can get all items that are not filtered and in the order they appear on the grid in the following way:

// using using Telerik.Windows.Data; 
// apply operations list Sorting, Filtering, etc to the original data
var pagerSource = this.pager.PagedSource as IEnumerable<Player>;
var allGridItems = pagerSource
    .AsQueryable<Player>()
    .Where(this.playersGrid.FilterDescriptors)
    .Sort(this.playersGrid.SortDescriptors)
    .GroupBy(this.playersGrid.GroupDescriptors)
    .ToIList();

This might still be a slow operation if you are dealing with a large collection. Could you please check if this approach will improve performance?


Sincerely yours,
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
Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Milan
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or