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

RadGridView ComboBox Column

5 Answers 1164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kevin Marois
Top achievements
Rank 1
Kevin Marois asked on 10 Oct 2011, 11:03 PM
I'm trying to add a combobox column to a RadGridView. My code is below. When I run it, I don't see the combo box.

 

<telerik:RadGridView x:Name="grdData"
                        Grid.Row="5"
                        Grid.Column="1"
                        Grid.ColumnSpan="10"
                        Margin="5"
                        AlternationCount="2"
                        AlternateRowBackground="LightBlue"
                        AutoGenerateColumns="False"
                        RowDetailsVisibilityMode="VisibleWhenSelected"
                        ItemsSource="{Binding GridData}">
  
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn x:Name="cboGrid"
                                        ItemsSource="{Binding GridData}"
                                        Width="75">
  
            <telerik:GridViewComboBoxColumn.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=PartNo}" Margin="4,0"/>
                        <TextBlock Text="{Binding Path=Descripton}" Margin="4,0"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:GridViewComboBoxColumn.ItemTemplate>
                              
        </telerik:GridViewComboBoxColumn>
  
        <telerik:GridViewDataColumn DataMemberBinding="{Binding PartNo}" Header="Part #"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Quantity}" Header="Quantity"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Descripton}" Header="Descripton"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Markup}" Header="Markup" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LineCost}" Header="Line Cost" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerCost}" Header="Customer Cost" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LineList}" Header="Line List" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ExtendedPrice}" Header="Extended Price" TextAlignment="Right"/>
    </telerik:RadGridView.Columns>
  
</telerik:RadGridView>

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 11 Oct 2011, 07:57 AM
Hi Kevin Marois,

Please take a look at our online documentation for a reference on how to define an ItemTemplate for your GridViewComboBoxColumn. Furthermore, I am sending you a sample project illustrating its implementation.
I hope it helps.
 

Kind regards,
Maya
the Telerik team

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

0
Kevin Marois
Top achievements
Rank 1
answered on 11 Oct 2011, 06:12 PM
Ok, this almost gets me what I need. What I'm trying to create is a grid with a combobox in column 1. When the combo is dropped down, I wouid like to have a listbox of data to pick from. The lists selected value then becomes the selected value for the combo box.

The ViewModel has a property called GridData which is the source of data for the grid, and a property called Parts which is the source for the list.

Hre's what I have so far, but it's not working:

<telerik:RadGridView x:Name="grdData"
                        Grid.Row="5"
                        Grid.Column="1"
                        Grid.ColumnSpan="10"
                        Margin="5"
                        AlternationCount="2"
                        ShowGroupPanel="False"
                        AlternateRowBackground="LightBlue"
                        AutoGenerateColumns="False"
                        RowDetailsVisibilityMode="Collapsed"
                        RowIndicatorVisibility="Collapsed"
                        ItemsSource="{Binding GridData}">
  
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding PartNo}" 
                                        ItemsSource="{Binding Parts}"
                                        SelectedValueMemberPath="PartNo">
            <telerik:GridViewComboBoxColumn.ItemTemplate>
                <DataTemplate>
                    <ListBox ItemsSource="{Binding Parts}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding PartNo}"/>
                                    <TextBlock Text="{Binding Manufacturer}"/>
                                    <TextBlock Text="{Binding Descripton}"/>
                                </StackPanel>                                                                
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </DataTemplate>
            </telerik:GridViewComboBoxColumn.ItemTemplate>
  
        </telerik:GridViewComboBoxColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Quantity}" Header="Quantity"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Descripton}" Header="Descripton"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Markup}" Header="Markup" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LineCost}" Header="Line Cost" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerCost}" Header="Customer Cost" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LineList}" Header="Line List" TextAlignment="Right"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ExtendedPrice}" Header="Extended Price" TextAlignment="Right"/>
    </telerik:RadGridView.Columns>
  
</telerik:RadGridView>

0
Maya
Telerik team
answered on 12 Oct 2011, 09:21 AM
Hi Kevin Marois,

Would you clarify a bit more your requirements ? What should be the difference between the scenario that you want to accomplish and the current state (when once you click on an item, it gets selected ) ?
Generally, modifying the ItemTemplate will change the way each of the items in the source of the combo box looks like. 
 

Greetings,
Maya
the Telerik team

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

0
Kevin Marois
Top achievements
Rank 1
answered on 12 Oct 2011, 05:25 PM
I am creating a grid of selected parts. In the first column the client wants a combobox that when dropped down provides list for selecting a new part.

See the image at the bottom of this page:  http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/WebGrid_Display_WebCombo_in_a_Cell.html
I want the same thing.

0
Maya
Telerik team
answered on 13 Oct 2011, 09:38 AM
Hi Kevin Marois,

As I could understand from the image you require to display a RadGridView inside the drop down. Am I right or am I missing something ? Generally, it is not quite recommended since placing such a heavy control inside an editing template might cause some degradation of your performance depending on the exact settings. Still, you could take a look at this blog post for a reference in case this is what you require.
Let me know in case of any misunderstandings.

Kind regards,
Maya
the Telerik team

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

Tags
GridView
Asked by
Kevin Marois
Top achievements
Rank 1
Answers by
Maya
Telerik team
Kevin Marois
Top achievements
Rank 1
Share this question
or