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

Row of ComboBox cells in RadGridView

3 Answers 123 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 09 Aug 2012, 10:25 PM
Hello.

I need to add a set of comboboxes as a new row to a RadGrid dynamically.  I've been able to get close by creating a ComboBoxCellElement off of GridDataCellElement and setting it inside the CreateCell event.  However, because of UI Virtualization, the comboboxes get re-used on different rows as I scroll around, and IsCompatible only seems to work when a custom column type is being used, which I am not using here.

Is it possible to apply specific controls to individual cells?  Or can UI Virtualization be turned off for RadGridView?

Thanks,
Mike

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 14 Aug 2012, 03:06 PM
Hello Michael,

You can implement the IsCompatible method in the following manner:
public class CustomCell : GridDataCellElement
   {
       public override bool IsCompatible(GridViewColumn data, object context)
       {
           return base.IsCompatible(data, context) && data.Name == "YourColumnName";
       }
   }

If the proposed solution does not fit your requirements, I would kindly ask you to share with us a sample code that shows how you create the cell and initialize the RadGridView control. Greetings,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Michael
Top achievements
Rank 1
answered on 14 Aug 2012, 04:10 PM
Thanks.  However, as mentioned, IsCompatible isn't useable here since I'm not declaring a custom column type --- I'm trying to place a combobox into a specific cell in a column that is otherwise a standard column.

I abandoned the Telerik controls and went with a standard MS DatagridView, which worked without issue.

Mike
0
Julian Benkov
Telerik team
answered on 20 Aug 2012, 08:12 AM
Hello Michael,

The cleanest solution for cases where you want a custom cell is to use it together  with a custom column. This prevents the mix up caused by the UI virtualization that you observed. Attached is a sample project where I have implemented the desired cell for column "2" of the new row in the grid. 

Alternative solution can be achieved by just replacing the editor of the desired cell, which does not require anything customer, just a few lines of code. However, this will not show the combo box until the cell goes in edit mode. This approach is also implemented in the attached solution.

I hope that you find this information useful.

Greetings, Julian Benkov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Svett
Telerik team
Michael
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or