RadComboBox inside a GridView feeded by RadDomainDataSource

5 posts, 0 answers
  1. Michele
    Michele avatar
    7 posts
    Member since:
    Jan 2012

    Posted 29 Jan 2012 Link to this post

    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.
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 02 Feb 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Michele
    Michele avatar
    7 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    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.

  5. Michele
    Michele avatar
    7 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    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.
  6. Michele
    Michele avatar
    7 posts
    Member since:
    Jan 2012

    Posted 05 Feb 2012 Link to this post

    Since it seems impossible to solve this problem, I will post it on another section...
Back to Top
DevCraft banner