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

GridViewComboBox horizontal scrolling performance

5 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 28 Sep 2010, 06:30 PM
Running the latest 9/24 SP2 build.  I'm going to include alot of information because I'm honestly not sure what matters and what doesn't.. so forgive some of what may be superfluous information.

I have a datagrid that has its columns generated based on user configuration at run time. {using grid.Columns.Add(x);}

This data grid is 38 columns wide.  Currently 16 of those columns are configured as combo box columns.

10 of them have very short itemsource lists.  (5 - 10 items)
6 of them have considerably longer itemsource lists (900- 2000).

Horizontal scrolling performance is very poor in this case.  CPU spikes to 50% on a Core2 Duo 2.8Ghz with 3GB RAM.

the most common probles I've been informed of is the RadGridView is housed in a container that disables column/row virtualization.  Below is my grid configuration, and my RadGridView declaration

<Grid.RowDefinitions>
    <RowDefinition Height="30" />
    <RowDefinition Height="55" />
    <RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>            
</Grid.ColumnDefinitions>
<telerik:RadGridView                      
    Grid.Row="2"
    ScrollViewer.HorizontalScrollBarVisibility="Auto"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    AutoGenerateColumns="false"
    Name="userGridView" 
    SelectionUnit="Cell"  
    ClipboardCopyMode="Default" 
    SelectionMode="Extended" 
    CanUserSortColumns="True"             
    Pasting="userGridView_Pasting"
    Pasted="userGridView_Pasted"
    KeyDown="userGridView_KeyDown"
    ItemsSource="{Binding}"
    telerik:Theming.Theme="Summer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" ></telerik:RadGridView>


What can I do to increase the performance here?  From what I read in the 9/24 release notes, the gridview was supposed to improve performance in these cases.

5 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 29 Sep 2010, 08:13 PM
anyone have any ideas?  This is very critical for our application.
0
Pavel Pavlov
Telerik team
answered on 30 Sep 2010, 04:00 PM
Hello Jason,

Indeed the latest build did include an improvement to the combo column - we have added element caching for the combobox column.

However  your case is a bit more complicated .I believe  the reason for the performance issue is that lookup logic ( e.g. finding the item in the combo items source ) is performed by RadGridView  in the UI layer . For less combo columns this is acceptable in matter of performance and flexibility. In cases when we have so many combo columns with large collections as items source, the time consumed by the lookup operations may significantly decrease performance.

Now I am thinking of some possibilities to optimize performance for your specific scenario:

It may be wise to relieve the UI from the lookup task and perform it at the data layer e.g :

Provide a ViewModel between the data and theRadGridView.ItemsSource  that has the values for the lookup fields prepopulated.  In case you can modify your business objects this may happen w/o a view model but in the business object code directly .

Then use a standard column to display the values  thus boosting performance at the UI layer.
Since we will need  a combo editor for the edit mode , this may be achieved by placing such , using the CellEditTemplate property.  Since only one editor is displayed at a time ( in the current cell only ) , we will have only one element performing lookup in the UI  when the cell is edited.  I believe this way we may gain significant performance boost.


I am aware that all this may sound obscure and/or complicated  so I offer you my assistance in implementing this , in case you decide to go that way.

In such case you may send me the implementation ( or a simplified version) of your business objects , and in return I will prepare a small app to demonstrate the approach .

All the best,
Pavel Pavlov
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
Jason
Top achievements
Rank 1
answered on 30 Sep 2010, 04:09 PM
That's an awesome idea Pavel thanks.

Let me ask one question though... in our case we have a display/actual value scenario

example

G1235 | Store 123 - New York,NY

what we store in the business object is "G1235" .. and our display value is  "Store 123 - New York,NY"

Does that still work with this approach? I'm thinking it could .. but I just wanted to make sur before you or I spent any more time with it.
0
Pavel Pavlov
Telerik team
answered on 30 Sep 2010, 04:32 PM
Hello Jason,

Yes that is the most common scenario - an ID value ( G1235) and a Display value( Store 123 - New York,NY)

So here , as mentioned , we have two choices :

1. We can expose the  Display proerty in the business object  and in  the getter write some logic to convert the ID to the Display value )
* this approach will require the business object to have a refference to the list with stores )

or

2. If we are not allowed to spoil the business object this way , we can provide a vew model to take care of the lookup logic.
* this approach will require the ViewModel  to have a refference to the list with stores )


Kind regards,
Pavel Pavlov
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
Jason
Top achievements
Rank 1
answered on 05 Oct 2010, 07:22 PM
GridViewDataColumn column = new GridViewDataColumn();
  
Binding propertyBinding = new Binding("bindingTarget");
column.DataMemberBinding = propertyBinding;
  
FrameworkElementFactory comboFactory = new FrameworkElementFactory(typeof(RadComboBox));
comboFactory.SetBinding(RadComboBox.SelectedValueProperty, propertyBinding);
comboFactory.SetValue(RadComboBox.SelectedValuePathProperty, "ActualValue");
comboFactory.SetValue(RadComboBox.DisplayMemberPathProperty, "DisplayValue");
comboFactory.SetValue(RadComboBox.ItemsSourceProperty, GetListValues());
DataTemplate comboBoxTemplate = new DataTemplate();
comboBoxTemplate.VisualTree = comboFactory;
column.CellEditTemplate = comboBoxTemplate;
column.CellEditTemplate.Seal();

This worked.  Also I turned off column virtualization and the performance was greatly improved.  Our dataset was approximately 40 items wide.  The datagrid now scrolls as impressively fast as it does in the demos.  Also this is created in code behind as opposed to xaml because the grid being displayed is defined by user configuration. They can configure the order and data elements placed into columns
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or