Hello,
I am having a performance problem with the combobox column of the RadGridView control. When bound to small data, the combobox works great, but when the data is large (18000+ items), the combobox seems very slow, frozes for 2 seconds when i enter edit mode, don't change the item and leave the edit mode, and frozes for 5 seconds when i change the selected item and leave the edit mode. I cannot accept this user experience. Is there a way to improve this performance?
I made a sample to show you the problem:
P.S.: I have to generate the columns in the code behind, because they are dynamic.
XAML:
<Window x:Class="TelerikWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Title="MainWindow" Height="350" Width="525">
<Grid>
<telerik:RadGridView Name="gridView" Grid.Row="0" ColumnWidth="*" AutoGenerateColumns="False"
SelectionMode="Extended" ScrollMode="Deferred" GroupRenderMode="Flat"/>
</Grid>
</Window>
Code Behind (C#):
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using Telerik.Windows.Controls;
namespace TelerikWpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
InitializeGrid();
}
private void InitializeGrid()
{
this.gridView.BeginInit();
this.gridView.Columns.Add(new GridViewSelectColumn());
this.gridView.Columns.Add(new GridViewDataColumn()
{
Header = "Order Id",
DataMemberBinding = new Binding("Id")
});
var comboColumn = new GridViewComboBoxColumn();
comboColumn.Header = "Client";
comboColumn.IsComboBoxEditable = true;
comboColumn.SelectedValueMemberPath = "Id";
comboColumn.DisplayMemberPath = "Name";
comboColumn.ItemsSource = getClients();
comboColumn.DataMemberBinding = new Binding("ClientId")
{
Mode = BindingMode.TwoWay
};
var style = new Style(typeof(RadComboBox));
style.Setters.Add(new Setter(RadComboBox.TextSearchModeProperty,
TextSearchMode.Contains));
comboColumn.EditorStyle = style;
this.gridView.Columns.Add(comboColumn);
comboColumn = new GridViewComboBoxColumn();
comboColumn.Header = "Product";
comboColumn.IsComboBoxEditable = true;
comboColumn.SelectedValueMemberPath = "Id";
comboColumn.DisplayMemberPath = "Name";
comboColumn.ItemsSource = getProducts();
comboColumn.DataMemberBinding = new Binding("ProductId")
{
Mode = BindingMode.TwoWay
};
style = new Style(typeof(RadComboBox));
style.Setters.Add(new Setter(RadComboBox.TextSearchModeProperty,
TextSearchMode.Contains));
comboColumn.EditorStyle = style;
this.gridView.Columns.Add(comboColumn);
this.gridView.ItemsSource = getOrders();
this.gridView.EndInit();
}
private DataView getOrders()
{
var dt = new DataTable();
dt.Columns.Add(new DataColumn()
{
ColumnName = "Id",
DataType = typeof(string),
MaxLength = 10
});
dt.Columns.Add(new DataColumn()
{
ColumnName = "ClientId",
DataType = typeof(string),
MaxLength = 10
});
dt.Columns.Add(new DataColumn()
{
ColumnName = "ProductId",
DataType = typeof(string),
MaxLength = 10
});
dt.Rows.Add(1, 1, 17000);
dt.Rows.Add(2, 2, 1892);
return dt.DefaultView;
}
private DataView getClients()
{
var dt = new Model();
dt.Rows.Add(1, "Walmart");
dt.Rows.Add(2, "Coca-Cola Company");
return dt.DefaultView;
}
private DataView getProducts()
{
var dt = new Model();
for (int i = 0; i < 18000; i++)
dt.Rows.Add(i, "Name " + i);
return dt.DefaultView;
}
}
}
Model Class:
using System;
using System.Data;
namespace TelerikWpfApp1
{
public class Model : DataTable
{
public Model() : base()
{
this.Columns.Add(new DataColumn()
{
ColumnName = "Id",
DataType = typeof(string),
MaxLength = 10
});
this.Columns.Add(new DataColumn()
{
ColumnName = "Name",
DataType = typeof(string),
MaxLength = 100
});
}
}
}