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

GridViewComboBoxColumn perormance, makes scrolling impossible

2 Answers 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Josip
Top achievements
Rank 1
Josip asked on 30 Aug 2011, 09:06 AM
Hi,
When i bind 3000 records in RadGrid (only one column) GridViewComboBoxColumn
i got terrible performance.

I need to do this from code behind.

to reproduce problem make WPF in Browser application, and add this page
<Page x:Class="Bug_Demo_ComboBoxColumn_Scroll.Page1"       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"        xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"       mc:Ignorable="d"        d:DesignHeight="300" d:DesignWidth="300"       Title="Page1">     <Grid>         <telerik:RadGridView              Name="dgDynGrid"                        AutoGenerateColumns="False"                            EnableColumnVirtualization="True"             EnableRowVirtualization="True"                         ShowGroupPanel="False"             IsFilteringAllowed="False"             DataLoadMode="Asynchronous"               CanUserInsertRows="True"                          CanUserResizeColumns="False"             CanUserFreezeColumns="False"             RowIndicatorVisibility="Collapsed"               />          </Grid> </Page>

Then make two classes:
    public class Persons     {         public int Id { getset; }         public string Name { getset; }         public string PlaceId { getset; }     }
    public class Place     {         public int PlaceId { getset; }         public string PlaceName { getset; }     }

in constructor of "Page1" fill test data:
List<Place> places = new List<Place>();             for (int i = 0; i < 3000; i++)             {                 Place p = new Place();                 p.PlaceId = i;                 p.PlaceName = "PlaceWithID" + i.ToString();                 places.Add(p);             }             List<Persons> persons = new List<Persons>();             for (int i = 0; i < 3000; i++)             {                 Persons p = new Persons();                 p.Id = i;                 p.PlaceId = i.ToString();                 persons.Add(p);             }

Add column:
Telerik.Windows.Controls.GridViewComboBoxColumn column = new Telerik.Windows.Controls.GridViewComboBoxColumn();             column.DataMemberBinding = new Binding("PlaceId");             column.DisplayMemberPath = "PlaceName";             column.SelectedValueMemberPath = "PlaceId";             column.ItemsSource = places;             dgDynGrid.Columns.Add(column);             dgDynGrid.ItemsSource = persons;

is it possible to turn on virtualization in GridViewComboBoxColumn ?


2 Answers, 1 is accepted

Sort by
0
Josip
Top achievements
Rank 1
answered on 01 Sep 2011, 02:26 PM
Hi,

Just wanted to send feedback.
I finally managed to put this to work fast :) hope it will help somebody

i replaced GridViewComboBoxColumn with RadComboBox (template in GridViewDataColumn )
 
Binding propertyBinding = new Binding("MyPropertyNameHere);                             
FrameworkElementFactory comboFactory = new FrameworkElementFactory(typeof(RadComboBox));
comboFactory.SetBinding(RadComboBox.SelectedValueProperty, propertyBinding);
comboFactory.SetValue(RadComboBox.IsReadOnlyProperty, false);
comboFactory.SetValue(RadComboBox.IsEnabledProperty, true);
//THIS WAS PERFORMANCE BOOST
comboFactory.SetValue(RadComboBox.ItemsPanelProperty, (ItemsPanelTemplate)Resources["VirtualizingStackPanelTemplate"]);

//TURN OFF virtualization on grid (if it contains this column type)
dgDynGrid.EnableRowVirtualization = false;                             
dgDynGrid.EnableColumnVirtualization = false;       

 column.IsGroupable = false;                             column.IsAutoGenerated = false;                             column.IsReadOnly = true;                             column.IsEnabled = false;                                                   comboFactory.SetValue(RadComboBox.SelectedValuePathProperty, "Key");                             comboFactory.SetValue(RadComboBox.DisplayMemberPathProperty, "Value");                             comboFactory.SetValue(RadComboBox.ItemsSourceProperty, GetItemSourceForColumn(kolonaEntiteta.ItemSource, kolonaEntiteta.ItemSourceKey, kolonaEntiteta.ItemSourceValue));                             DataTemplate template = new DataTemplate();                             template.VisualTree = comboFactory;                             template.Seal();                             column.CellTemplate = template;
                     
0
Pavel Pavlov
Telerik team
answered on 03 Sep 2011, 08:20 AM
Hello Josip,

Thank you for sharing the workaround! Indeed this will be useful for the community. This is a valuable contribution . I am updating your Telerik points.

Greetings,
Pavel Pavlov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Josip
Top achievements
Rank 1
Answers by
Josip
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or