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

RadComboBox inside a GridView feeded by RadDomainDataSource

4 Answers 136 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 1
Michele asked on 29 Jan 2012, 05:40 PM
Hello,
I've two entities, Products and Categories, classically related as in the picture attached.
In my XAML page, I've two controls feeding two different RadDomainDataSource, one for the Products and the other for the Categories coming from the RIA Services.

I have to build a RadGridView which main ItemsSource is the RadDomain of the Products while in a column I would like to show a RadComboBox showing the current category and letting the user choose another one.

The code is as follows.

<Grid x:Name="LayoutRoot" Background="White">
    
<telerik:RadDomainDataSource x:Name="ddsCategories" AutoLoad="true" PageSize="20" QueryName="GetCategories">
        <telerik:RadDomainDataSource.DomainContext><business:dsPuraMater></business:dsPuraMater></telerik:RadDomainDataSource.DomainContext>
    
</telerik:RadDomainDataSource>         
    <telerik:RadDomainDataSource x:Name="ddsProdotti" AutoLoad="true" PageSize="20" QueryName="GetProducts">
       <telerik:RadDomainDataSource.DomainContext><business:dsPuraMater></business:dsPuraMater></telerik:RadDomainDataSource.DomainContext>         
    </telerik:RadDomainDataSource>         
    
    <
telerik:RadGridView x:Name="grProducts" AutoGenerateColumns="False" CanUserFreezeColumns="False" HorizontalAlignment="Stretch"                                               
    IsBusy
="{Binding IsBusy, ElementName=ddsProdotti}" ItemsSource="{Binding DataView, ElementName=ddsProdotti}"
    RowDetailsVisibilityMode="VisibleWhenSelected" RowIndicatorVisibility="Collapsed" ShowGroupFooters="False" 
    ShowGroupPanel
="False" ShowInsertRow="True" VerticalAlignment="Stretch" telerik:StyleManager.Theme="Metro">
            <telerik:RadGridView.Columns>
                
<telerik:GridViewToggleRowDetailsColumn ExpandMode="Single" />
                
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name, Mode=TwoWay}" Header="Nome" Width="200"></telerik:GridViewDataColumn>
               <telerik:GridViewColumn Header="Category" Width="200"  >
                    
<telerik:GridViewColumn.CellTemplate>
                        
<DataTemplate>
                            
<telerik:RadComboBox x:Name="myCombo"  Width="170" Height="20" telerik:StyleManager.Theme="Metro"
                            SelectedItem="{Binding Binding SelectedItem.Category}"
                           DisplayMemberPath="Name_IT"
                           ItemsSource="{Binding DataView, ElementName=ddsCategories}">
                            </telerik:RadComboBox>                         
                        </DataTemplate>                     
                    </telerik:GridViewColumn.CellTemplate>                 
                </telerik:GridViewColumn>             
            
</telerik:RadGridView.Columns>
        
</telerik:RadGridView>     
</Grid>

Unfortunately, more than not to show the selected category of the item related to the particular row,
the combobox has no items at all. Of course, I've modified the RIA service in the query GetCategories to Include() also the Products.
And, if I try to fill the radcombobox outside the RadGridView (without Selecteditem part), the combo is filled
in the right way.

Where's the error?

Thanks a lot.

4 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 02 Feb 2012, 08:52 AM
Hello Michele,

I think to make it work, you need to set the ElementName of the Binding of the ComboBox. For example:

<telerik:RadComboBox x:Name="myCombo"  Width="170" Height="20" telerik:StyleManager.Theme="Metro"                            SelectedItem="{Binding ElementName=ddsProdotti, Path=SelectedItem.Category}"                            DisplayMemberPath="Name_IT"                            ItemsSource="{Binding DataView, ElementName=ddsCategories}">                             </telerik:RadComboBox>

Also, you have to make sure that the items of the ComboBox are already loaded, before selecting the item.
This is an issue with the ComboBox that if the items are loaded one by one and the first is not the one that needs to be selected, the ComboBox stops looking for the searched one.

Hope this information helps.

Kind regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Michele
Top achievements
Rank 1
answered on 02 Feb 2012, 03:44 PM
Dear Konstantina,
thanks for your help but unfortunately setting the ElementName in the SelectedItem tag do not solve the problem.
The fact is that the RadComboBox is completely void, with no items, even if I set the IsBusy property of the GridView containing the RadComboBox to False only after the complete loading of its DomainDataSource.

0
Michele
Top achievements
Rank 1
answered on 02 Feb 2012, 05:40 PM
PS: With the same code outside the GridView (except for the SelectedItem that would have no sense there), the RadComboBox is filled in the right way.
0
Michele
Top achievements
Rank 1
answered on 05 Feb 2012, 10:33 AM
Since it seems impossible to solve this problem, I will post it on another section...
Tags
ComboBox
Asked by
Michele
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Michele
Top achievements
Rank 1
Share this question
or