Syncronising current grid item with usercontrol

6 posts, 0 answers
  1. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Hi.

    I have a page where I have a domain datasource setup to return a "data_PERSON" object which has linked entities, namely "data_DEPENDANT". I have a user control that has the radgridview to show the "data_DEPENDANTs" and a second user control that is used to show the currently selected "data_DEPENDANT";

    Main page xaml;

    <Grid x:Name="LayoutRoot" Background="LightGray" DataContext="{Binding ElementName=dds, Path=Data}" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="800" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
      
            <riaControls:DomainDataSource x:Name="dds"  AutoLoad="True" QueryName="GetData_PERSON">
                <riaControls:DomainDataSource.DomainContext>
                    <domain:AppDomainContext />
                </riaControls:DomainDataSource.DomainContext>
                  
            </riaControls:DomainDataSource>
             
                              
                <Border Grid.Row="1" Grid.Column="0" Margin="10,-30,10,10" CornerRadius="10" Background="White" 
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
      
                 
                <Grid  x:Name="container1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                          
      
            </Border>
      
            <Border Grid.Row="1" Grid.Column="1" Margin="10,-30,10,10" CornerRadius="10" Background="White" 
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                <Grid  x:Name="container2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            </Border>
      
            
        </Grid>

    The grid usercontrol is loaded through code-behind into "container2" and the details is loaded into "container1"; XAML for the grid follows;

    <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
                   <telerik:RadGridView x:Name="radGridView1" telerik:StyleManager.Theme="Windows7"
               IsReadOnly="False" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed"
               GroupPanelForeground="#FF1E395B" Margin="4"
               GroupPanelStyle="{StaticResource GridViewGroupPanelStyle}" 
               BorderBrush="#FFA0AFC3"
               ItemsSource="{Binding Path=data_DEPENDANT, Mode=TwoWay}"
               IsSynchronizedWithCurrentItem="True"            
                                >
               <telerik:RadGridView.Columns>
                   <telerik:GridViewDataColumn Header="Dependants Name" Width="*"  DataMemberBinding="{Binding Path=name}"/>               
               </telerik:RadGridView.Columns>  
           </telerik:RadGridView>
       </Grid>

    This correctly shows the child values in "data_DEPENDANT". However when I select an item in the grid I need the data to be shown on in the details control loaded to "container1". I have tried all types of binding however no data is viewed. I need the data to be shown and updated. XAML for the details control follows;

    <Grid Margin="10,10,30,10">
                    <StackPanel Orientation="Vertical">
                        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,1,0,0">
                            <TextBlock Text="Name" Width="120"  VerticalAlignment="Center" />
                    <telerikInput:RadMaskedTextBox  MaskType="None" 
                                                   Width="220" Grid.Column="1"
                                                    telerik:StyleManager.Theme="Windows7"
                                                    Value="{Binding Path=data_DEPENDANT.name}"/>

  2. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Code-behind loading the controls is

    clearContainers();
                    container1.Children.Add(new DependantDetailsControl());
                    container2.Children.Add(new DependantDetailsGridControl());
  3. DevCraft banner
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Aug 2010 Link to this post

    Hi madladuk,

    Since the Data property of the DomainDataSource is set as Datacontext you should modify the binding a bit: 

    <telerikInput:RadMaskedTextBox  MaskType="None" 
                                                   Width="220" Grid.Column="1"
                                                    telerik:StyleManager.Theme="Windows7"
                                                    Value="{Binding Path=CurrentItem.name}"/>


    Kind regards,
    Milan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 17 Aug 2010 Link to this post

    Tried that and still no data, the radtextbox is in another usercontrol within the same page where the dds is. Any further ideas?
  6. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 17 Aug 2010 Link to this post

    CurrentItem returns me the data_PERSON object which is the top level object where as the grid is bound to data_DEPENDANT which is a sub entity, so it looks as if the grid is not changing the record?

    Thus

    data_PERSON <- Main page binding
            data_DEPENDANT <- user control with grid
            data_DEPENDANT


    Thanks
    P
  7. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 18 Aug 2010 Link to this post

    Sorted it, used a delegate event to post the grid selected item to the main page which then resets the context in the second user control.

    Thanks
    P
Back to Top
DevCraft banner