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

[Solved] Using RadGridView in RadComboBox ItemTemplate

3 Answers 306 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Charles Macleod
Top achievements
Rank 1
Charles Macleod asked on 12 Jan 2010, 06:54 AM
Hi,
I am having no luck using a RadGridView inside the ItemTemplate of a RadComboBox. The issue seems to be the binding of the ItemSource of the RadGridView. If I use a "regular" grid, as below, the binding works fine.

Given this class definition:

public class LandManagement {
    public string ManagementName { get; set; }
    public string ManagementSystemType {get; set;}
    public double AreaCovered { get; set;}
}

And an Observable collection of LandManagements - "ManagementChoices", This works like a champ.

 
<telerikComboBox:RadComboBox x:Name="LUBTMgmtComboBox"   
                        ItemsSource="{Binding ManagementChoices}" 
                        telerik:TextSearch.TextPath="ManagementName" 
                        Style="{StaticResource ComboStyle}" 
                        SelectionBoxItemTemplate="{StaticResource RadComboSelectedItem}">  
                    <telerikComboBox:RadComboBox.ItemTemplate> 
                        <DataTemplate> 
                            <Grid> 
                                <Grid.ColumnDefinitions> 
                                    <ColumnDefinition Width="2*"/>  
                                    <ColumnDefinition Width="Auto"/>  
                                    <ColumnDefinition/> 
                                </Grid.ColumnDefinitions> 
                                  
                                <TextBlock Grid.Column="0" Text="{Binding ManagementName}"/>  
                                <Border Background="AliceBlue" Grid.Column="1">  
                                    <TextBlock Padding="3 0 0 2" Grid.Column="1" Text="{Binding ManagementSystemType}"/>  
                                </Border> 
                                <TextBlock Grid.Column="2" Padding="4 0 0 2" 
                                    Text="{Binding AreaCovered, Converter={StaticResource standAreaConverter}}"/>  
                            </Grid> 
                        </DataTemplate> 
                    </telerikComboBox:RadComboBox.ItemTemplate> 
            </telerikComboBox:RadComboBox> 
 

 


However, when I replace the "regular" grid with the RadGridView, it is clear that the binding has failed. Does anyone have an example of using a RadGridView in the combo box popup or see anything wrong/incomplete with my xaml.

This does not work - I see only the values "ManagementName","ManagementSystemType", etc. for each row in the popup grid. Clearly the binding is broken/incorrrect in the RadGridView:

 

 

 

 
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>  
<telerikComboBox:RadComboBox x:Name="LUBTMgmtComboBox"   
                        ItemsSource="{Binding ManagementChoices}" 
                        telerik:TextSearch.TextPath="ManagementName" 
                        Style="{StaticResource ComboStyle}" 
                        SelectionBoxItemTemplate="{StaticResource RadComboSelectedItem}">  
                    <telerikComboBox:RadComboBox.ItemTemplate> 
                        <DataTemplate> 
                            <telerikGrid:RadGridView x:Name="LUBTMgmtGridView" 
                                                     AutoGenerateColumns="False"   
                                                     ShowGroupPanel="False">  
 
                                <telerikGrid:RadGridView.Columns> 
                                    <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding ManagementName}" Header="Management"/>  
                                    <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding ManagementSystemType}" Header="Mgmt Type"/>  
                                    <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding AreaCovered, Converter={StaticResource AreaConverter}}" Header="Area Covered" IsGroupable="False"/>  
                                </telerikGrid:RadGridView.Columns> 
                            </telerikGrid:RadGridView> 
                        </DataTemplate> 
                    </telerikComboBox:RadComboBox.ItemTemplate> 
                </telerikComboBox:RadComboBox> 

 

 


Thanks a lot
Charlie

3 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 13 Jan 2010, 10:28 AM
Hello Charles,

As I understand in your case you are trying to replace Grid element with RadGridView control.

First let me give some information about these controls.

The Grid is a layout control used as a container for other Silverlight controls.  In some scenarios it can replaced by StackPanel or Canvas. It can only align its contents.

Despite the Grid, RadGridView is Data visualization control. It is used display set of data (Lists, data tables, etc.). It is similar to ListBox and DataGrid. RadGridView can dynamically load contents depending on the provided data.

In your case when you are using Grid you are just aligning textblocks and borders.
However the added RadGridView expects some data to visualize. Data need to be provided through ItemSource property (similar to RadComboBox or Listbox). Since there is no such data the bindings within the columns throw exceptions.

About nesting RadGridView withing RadComboBox itemTemplate - yes, it is possible although not very practical. I have attached simple example that demonstrates how this can be achieved.

I hope this helps. If you have any more questions do not hesitate to contact us.

Best wishes,
Tsvyatko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kwinten Volckaert
Top achievements
Rank 1
answered on 08 Mar 2011, 10:55 AM
I'm looking to achieve the same...however, the link doesn't seem to work anymore...
0
Vlad
Telerik team
answered on 08 Mar 2011, 12:33 PM
Hello,

 I've just checked the link to the project and everything worked normally on my end. 

Regards,
Vlad
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Charles Macleod
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Kwinten Volckaert
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or