RadGridView ComboBox Column

6 posts, 0 answers
  1. Kevin Marois
    Kevin Marois avatar
    16 posts
    Member since:
    May 2010

    Posted 10 Oct 2011 Link to this post

    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>

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Oct 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kevin Marois
    Kevin Marois avatar
    16 posts
    Member since:
    May 2010

    Posted 11 Oct 2011 Link to this post

    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>

  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Oct 2011 Link to this post

    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 >>

  6. Kevin Marois
    Kevin Marois avatar
    16 posts
    Member since:
    May 2010

    Posted 12 Oct 2011 Link to this post

    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.

  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 13 Oct 2011 Link to this post

    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 >>

Back to Top
UI for WPF is Visual Studio 2017 Ready