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

How to set properties to a combo box that is inside a Grid

1 Answer 84 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Parameswari
Top achievements
Rank 2
Parameswari asked on 25 Nov 2011, 07:31 AM

Hi,
  In my design ,I have a grid ,one of the column of the grid is combobox control.
 In the combo box- drop down, I have binded Customer ID and CustomerName using EditorStyle.
 The issue is the drop down list the Items in ascending order of the CustomerID ,But I need to display the items in Descending order of CustomerName .Is there any property to achieve it?  Kindly help us to solve the problem.
Below is the Code snippet:

<TelerikGrid:GridViewComboBoxColumn x:Name="CmbItm" Width="2*" IsComboBoxEditable="True" IsFilterable="True"
         DataMemberBinding="{Binding CustomerID}" UniqueName="Customer_Vendor"
         DisplayMemberPath="CustomerName" Header="Customer/Vendor"
         SelectedValueMemberPath="CustomerID"                                                                                                                              
          ItemsSource="{Binding Path=Customer,    Source={StaticResource journalentryViewModel}}">
                <TelerikGrid:GridViewComboBoxColumn.CellStyle>
                            <Style TargetType="TelerikGrid:GridViewCell">
                                        <Setter Property="Height" Value="19"/>
                                    </Style>
                                </TelerikGrid:GridViewComboBoxColumn.CellStyle>
                                <TelerikGrid:GridViewComboBoxColumn.EditorStyle >
                                    <Style TargetType="TelerikCombo:RadComboBox" >
                                        <Setter Property="MinHeight" Value="15"/>
                                        <Setter Property="Height" Value="19"/>                                          
                                        <Setter Property="Margin" Value="0"/>
                                        <Setter Property="ItemContainerStyle">
                                            <Setter.Value>
                                                <Style TargetType="TelerikCombo:RadComboBoxItem">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate>
                                                                <Grid>
                                                                    <Grid.RowDefinitions >
                                                                        <RowDefinition/>
                                                                    </Grid.RowDefinitions>
                                                                    <Grid.ColumnDefinitions>
                                                                        <ColumnDefinition />
                                                                        <ColumnDefinition />
                                                                        <ColumnDefinition />
                                                                    </Grid.ColumnDefinitions>
                                                                    <TextBlock Text="{Binding CustomerName}" Grid.Row="0" Grid.Column="0"  Width="256" />
                                                                    <TextBlock Text="{Binding CustomerID}" Grid.Row="0" Grid.Column="1" Width="0" />
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </TelerikGrid:GridViewComboBoxColumn.EditorStyle>
                            </TelerikGrid:GridViewComboBoxColumn>

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 25 Nov 2011, 08:44 AM
Hello Parameswari,

RadComboBox cannot sort its items, but if you sort its items source the control will display the items in the correct order.

All the best,
Valeri Hristov
the Telerik team

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

Tags
ComboBox
Asked by
Parameswari
Top achievements
Rank 2
Answers by
Valeri Hristov
Telerik team
Share this question
or