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

GridViewComboBoxColumn values are hidden when using ComboBox DataTemplate

1 Answer 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erez
Top achievements
Rank 1
Erez asked on 07 Jun 2009, 05:29 PM
Hello,
I'm using dotnet 3.5, WPF.
XP pro SP3.
IE6.0.2900
RadControls_for_WPF_2009_1_0526_TRIAL
C#

I have created a simple RadGridView  with a GridViewComboBoxColumn column.
I have added a combobox "DataTemplate" so that the column cells will look like a combo, and not just
when pressing on one of the cells.

In the constructor of the window1, I call FillStatusComboColumn() to fill the combo with possible values.

*** The problem is that using the "DataTemplate" in the XAML causes the values in the
combobox to disappear. ***

Any ideas ?

Thanks

E. S

<telerik:RadGridView  Name="RadGridView1"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
AutoGenerateColumns="False"
ShowGroupPanel="False"
IsFilteringAllowed="False">
<telerik:RadGridView.Columns>
 <telerik:GridViewComboBoxColumn UniqueName="Status"
                                 HeaderText="STATUS">
 <telerik:GridViewColumn.CellTemplate>
   <DataTemplate>
      <ComboBox />
   </DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
 

private void FillStatusComboColumn()
{
var comboColumn = (Telerik.Windows.Controls.
GridViewComboBoxColumn)RadGridView1.Columns["Status"];
comboColumn.DataMemberBinding = new Binding("ActivityType");
comboColumn.ItemsSource = GetActivityTypes();
comboColumn.DisplayMemberPath =
"Name";
comboColumn.SelectedValueMemberPath =
"ID";
}

public class ActivityType
{
public string Name
{
get;
set;
}

public int ID
{
get;
set;
}

}

private System.Collections.IEnumerable GetActivityTypes()
{
List<ActivityType> ActivityTypes = new List<ActivityType>();

ActivityTypes.Add(new ActivityType() { ID = 0, Name = "" });
ActivityTypes.Add(new ActivityType() { ID = 1, Name = "Val1" });
ActivityTypes.Add(new ActivityType() { ID = 2, Name = "Val2" });
ActivityTypes.Add(new ActivityType() { ID = 3, Name = "Val3" });

return ActivityTypes;

}

1 Answer, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 10 Jun 2009, 05:51 AM
Hi Erez,

When you define CellTemplate you need to fill your combo - column ItemsSource will work only for automatically generated combo in edit mode. The grid cannot know what kind of controls you have defined in your template and that is why cannot fill/databind these controls.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Erez
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or