RadComboBox within DataGrid

3 posts, 0 answers
  1. Geoff Ables
    Geoff Ables avatar
    1 posts
    Member since:
    Dec 2004

    Posted 23 Sep 2008 Link to this post

    When I put the RadCombo in a DataGridTemplateColumn, it displays only the first item and selecting the expand error does not expand the list.  The xaml below results in the 'Ascending' Combobox being displayed in each row, but does not allow changing the selection or even showing that there is other selections


    my:DataGrid x:Name="gridColumns" AutoGenerateColumns="False" >


    <my:DataGridTextColumn Header="Column Name" DisplayMemberBinding="{Binding ColumnName}"/>

    <my:DataGridTextColumn Header="Alias" DisplayMemberBinding="{Binding Alias}"/>

    <my:DataGridTextColumn Header="Table" DisplayMemberBinding="{Binding Table}"/>

    <my:DataGridCheckBoxColumn Header="Output" DisplayMemberBinding="{Binding Output}"/>

    <my:DataGridTemplateColumn Header="Sort Type">



    <Grid >

    <telerik:RadComboBox SelectedItem="{Binding SortType}" >

    <telerik:RadComboBoxItem Content="Ascending" />

    <telerik:RadComboBoxItem Content="Descending" />








  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 25 Sep 2008 Link to this post

    Hi Geoff,

    I managed to reproduce the problem. It appears that the combo box dropdown is not measured correctly when the combo is placed in CellTemplate, but works properly when it is placed in CellEditingTemplate. We are planning an update of RadControls for Silverlight in several days and I will try to include the fix if this problem in it.

    Unfortunately, at this moment I am unable to offer a quick workaround, different than using RadComboBox in CellEditingTemplate, instead of CellTemplate.

    I am sorry for the inconvenience.

    All the best,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Simon Kingaby
    Simon Kingaby avatar
    24 posts
    Member since:
    Apr 2008

    Posted 31 Oct 2008 Link to this post

    This is currently a bug in the Silverlight DataGrid control.  When a ComboBox or RadComboBox is included in a DataGridTemplateColumn.CellEditingTemplate,  the ComboBox dropdown autohides immediately after clicking the dropdown button. 

    Manish Dalal's blog has the fix for this:  http://weblogs.asp.net/manishdalal/archive/2008/09/28/combobox-in-datagrid.aspx 

    You first create a utility class that will provide the "keep drop list open" service to the combo box, like this:

    Imports Telerik.Windows.Controls  
    Public Class RadComboBoxService  
        Public Shared ReadOnly ForceOpenProperty As DependencyProperty = _  
            DependencyProperty.RegisterAttached("ForceOpen"GetType(Boolean), GetType(RadComboBoxService), New PropertyMetadata(AddressOf OnForceOpenChanged))  
        Public Shared Function GetForceOpen(ByVal d As DependencyObject) As Boolean 
            Return d.GetValue(ForceOpenProperty)  
        End Function 
        Public Shared Sub SetForceOpen(ByVal d As DependencyObject, ByVal value As Boolean)  
            d.SetValue(ForceOpenProperty, value)  
        End Sub 
        Private Shared Sub OnForceOpenChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)  
            Dim comboBox = DirectCast(d, RadComboBox)  
            If CBool(e.OldValue) Then 
                RemoveHandler comboBox.Loaded, New RoutedEventHandler(AddressOf comboBox_Loaded)  
            End If 
            If CBool(e.NewValue) Then 
                AddHandler comboBox.Loaded, New RoutedEventHandler(AddressOf comboBox_Loaded)  
            End If 
        End Sub 
        Shared Sub comboBox_Loaded(ByVal sender As ObjectByVal e As RoutedEventArgs)  
            Dim comboBox = DirectCast(sender, RadComboBox)  
            If comboBox Is Nothing Then 
                comboBox = DirectCast(e.OriginalSource, RadComboBox)  
            End If 
            comboBox.IsDropDownOpen = True 
        End Sub 
    End Class 

    You then use the service in the XAML declaration of your RadComboBox like this:

            <telerik:RadComboBox x:Name="DealTypeIdCombo" Margin="1,0,1,0"   
    Width="200" DisplayMemberPath="Descr" VerticalAlignment="Center" 
    Height="25" SelectedItem="{Binding DealTypeId, Mode=TwoWay}" 
    ItemsSource="{Binding SourceDealTypes, Source={StaticResource localItemSource}}" 

    Notice the attribute local:RadComboBoxService.ForceOpen="true"
Back to Top