Selectable null value in GridViewComboBoxColumn

6 posts, 0 answers
  1. Franziska
    Franziska avatar
    29 posts
    Member since:
    Dec 2009

    Posted 12 Oct 2011 Link to this post

    Hi,

    How can I set properties of the ComboBox's in a GridViewComboBoxColumn.

    I want to set the ClearSelectionButtonVisibility and ClearSelectionButtonContent properties as described in this thread
    http://www.telerik.com/community/forums/wpf/combobox/selectable-null-value-in-radcombobox.aspx

    I have tried it with a style in the GridViewComboBoxColumn ressources:

    <telerik:GridViewComboBoxColumn.Resources>
        <Style TargetType="Controls:RadComboBox">
            <Setter Property="ClearSelectionButtonVisibility" Value="Visible" />
            <Setter Property="ClearSelectionButtonContent" Value="Test" />
        </Style>
    </telerik:GridViewComboBoxColumn.Resources>


    This approach is not working.

    Thanks and regards,

    Franziska
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Oct 2011 Link to this post

    Hi Franziska,

    You could define the style in the grid's Resources section. For example:

    <telerik:RadGridView Name="playersGrid"
                         ItemsSource="{Binding Players}"
                         AutoGenerateColumns="False">
        <telerik:RadGridView.Resources>
            <Style TargetType="telerik:RadComboBox" >
                <Setter Property="ClearSelectionButtonVisibility" Value="Visible" />
                <Setter Property="ClearSelectionButtonContent" Value="test" />
            </Style>
        </telerik:RadGridView.Resources>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
            <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ClubID}"
                                            ItemsSource="{Binding Clubs, Source={StaticResource MyViewModel}}"
                                            SelectedValueMemberPath="ID"
                                            DisplayMemberPath="Name" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
     
    Furthermore, please remember that in order not to get any validation errors, the underlying property (in the case above ClubID) should be nullable.

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Franziska
    Franziska avatar
    29 posts
    Member since:
    Dec 2009

    Posted 12 Oct 2011 Link to this post

    Hi Maya,

    Thanks for you quick response.

    This is the same what I did, but it affects all the telerik:GridViewComboBoxColumn 's.
    I only want to apply the style to certain columns. It does not work if I define the style in the resources of the telerik:GridViewComboBoxColumn 

    Thanks,

    Franziska
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Oct 2011 Link to this post

    Hi Franziska,

    If you want to set this style only for a particular column, you can define a key attribute for it and set it to the EditorStyle of that particular column. For example:

    <telerik:RadGridView Name="playersGrid"
                                 ItemsSource="{Binding Players}"
                                 AutoGenerateColumns="False">
                <telerik:RadGridView.Resources>
                    <Style x:Key="myStyle" TargetType="telerik:RadComboBox" >
                        <Setter Property="ClearSelectionButtonVisibility" Value="Visible" />
                        <Setter Property="ClearSelectionButtonContent" Value="test" />
                    </Style>
                </telerik:RadGridView.Resources>
                <telerik:RadGridView.Columns>                
                    <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ClubID}"
                                                    EditorStyle="{StaticResource myStyle}"
                                                    ItemsSource="{Binding Clubs, Source={StaticResource MyViewModel}}"
                                                    SelectedValueMemberPath="ID"
                                                    DisplayMemberPath="Name" />            
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

    Best wishes,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Franziska
    Franziska avatar
    29 posts
    Member since:
    Dec 2009

    Posted 12 Oct 2011 Link to this post

    Hi Maya,

    That is exactly, what I was looking for.

    One last question... Is there an easy way to change the style of the ClearButton to look like a normal RadComboBoxItem?

    At the moment I am trying to change the style of the button to look like the other items... but it is hard to find out the exact same values of the RadComboBoxItems sytles.

    Thanks
    Franziska
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Oct 2011 Link to this post

    Hello Franziska,

    You could try to create a style targeting RadButton. It could be something similar to:

    <telerik:RadGridView.Resources>
                    <Style TargetType="telerik:RadButton">
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="BorderThickness" Value="0" />
                        <Setter Property="HorizontalContentAlignment" Value="Left" />
                        <Setter Property="Padding" Value="6,0,0,0" />
                    </Style>
                    <Style x:Key="myStyle" TargetType="telerik:RadComboBox" >
                        <Setter Property="ClearSelectionButtonVisibility" Value="Visible" />
                        <Setter Property="ClearSelectionButtonContent" Value="test" />
                    </Style>
                </telerik:RadGridView.Resources>


     

    Regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top