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

Adding several combobox columns with large data as itemssource , scrolling loses performance.

1 Answer 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anji
Top achievements
Rank 1
Anji asked on 13 Sep 2011, 08:57 PM
Adding  several combobox columns with large data as itemssource , scrolling loses performance.
How can i increase the performance of the Scrolling?

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Sep 2011, 01:28 PM
Hi Anji,

The reason for the performance problem observed is indeed the size of the ItemsSource for the combo columns.
For each cell RadGridView needs to perform some lookup logic in order to match the selected value with the display value.  When the source for the combo is large this takes a lot of time .

A chance for improvement would be the following code :
public class OptimizedComboColumn : GridViewComboBoxColumn
    {
        public override System.Windows.FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            QueryableCollectionView filteredSource = new QueryableCollectionView(this.ItemsSource);
 
            Type type = filteredSource.GetItemAt(0).GetType();
             
            var selectionPropertyInfo = dataItem.GetType().GetProperty(this.DataMemberBinding.Path.Path);
            var displayPropertyInfo = type.GetProperty(this.DisplayMemberPath);
 
            var selectionProperty = selectionPropertyInfo.GetValue(dataItem,null);
            filteredSource.FilterDescriptors.Add(new FilterDescriptor(this.SelectedValueMemberPath, FilterOperator.IsEqualTo, selectionProperty));
            TextBlock textBlock = new TextBlock();
            var item = filteredSource.GetItemAt(0);
            string displayValue = displayPropertyInfo.GetValue(item, null).ToString();
 
            return new TextBlock() { Text = displayValue };
        }
    }

This is a derivate of the standard GridViewCombo column. It involves some hacks to pass a filtered source to the element in display mode. Replacing the standard combo column with this one should improve the situation in your scenario.

Let me know in case you have troubles implementing this in your production code.


Best wishes,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

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