Binding Dynamic GridView Data with ComboBox Columns

2 posts, 0 answers
  1. Lars
    Lars avatar
    8 posts
    Member since:
    Oct 2012

    Posted 20 Mar 2013 Link to this post

    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
  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 25 Mar 2013 Link to this post

    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.

Back to Top