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

Syncronising current grid item with usercontrol

5 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
madladuk
Top achievements
Rank 2
madladuk asked on 16 Aug 2010, 04:27 PM
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}"/>

5 Answers, 1 is accepted

Sort by
0
madladuk
Top achievements
Rank 2
answered on 16 Aug 2010, 04:28 PM
Code-behind loading the controls is

clearContainers();
                container1.Children.Add(new DependantDetailsControl());
                container2.Children.Add(new DependantDetailsGridControl());
0
Milan
Telerik team
answered on 17 Aug 2010, 02:05 PM
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
0
madladuk
Top achievements
Rank 2
answered on 17 Aug 2010, 04:10 PM
Tried that and still no data, the radtextbox is in another usercontrol within the same page where the dds is. Any further ideas?
0
madladuk
Top achievements
Rank 2
answered on 17 Aug 2010, 04:15 PM
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
0
madladuk
Top achievements
Rank 2
answered on 18 Aug 2010, 02:01 PM
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
Tags
GridView
Asked by
madladuk
Top achievements
Rank 2
Answers by
madladuk
Top achievements
Rank 2
Milan
Telerik team
Share this question
or