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

Binding Dynamic GridView Data with ComboBox Columns

1 Answer 185 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 20 Mar 2013, 02:25 PM
Hi,
I'm having an issue that's been going around for a few days, and I haven't found a solution yet. Here's the problem. I have data that I need to bind to the RadGridView, but the data changes all the time, and I have to let the gridview be flexible to handle whatever I throw at it. The first suggestion would be to create a DataTable with custom columns...well that worked at first, but we need to add ComboBoxColumns to the grid with pre-selected values from lists, so a DataTable is out.

I ended up binding the the GridView columns and Itemssource to Model objects, and the Itemssource was a List of "dynamic" objects, with custom properties. That worked, and allowed me to bind the gridView to custom data and have pre-selected ComboBox columns working. HOWEVER, it's just sooo slow. Have yall encountered this question before and did you find a way to speed things up, or is there a better way to bind the data?

I tried binding to a Dictionary<string, object>, but of course that won't work, because the columns are looking for object properties, not a property of type Dictionary with fields, so then the binding never happens. I also looked at your examples of binding with multiple data sources, but didn't see quite the exact same scenario.

Thanks,
Ryan

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 25 Mar 2013, 12:29 PM
Hi,

Indeed there are some known performance issues with "ComboBox" columns. The problem comes from the fact that for every single cell from that column a new ComboBox control is created, which means the entire "ItemsSource" is loaded and then this "ItemsSource" is searched in order to get the selected value. The best approach if you are using a lot of items as ComboBox.ItemsSource is to use separate cell templates for view and edit. You can customize the view template to be an ordinary TextBlock, while edit template to be ComboBox. This setup will load "ItemsSource" only when cell enters into an edit mode and overall performance will increase significantly. For more information how to use different CellTemplates you can take a look at this online example. The example is for Silverlight but same applies to WPF as well.

Kind regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Lars
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or