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

GridView Data Reset When RadPane Docked

2 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 04 Apr 2014, 05:38 AM
I have a RadGridView hosted with a RadPane.  The GridView uses a row style to highlight those rows where "IsSelected" is true however whenever any panes are added to the RadPaneGroup or the docking of any Pane (including the pane with the GridView) is changed, all of the "Selected" checkboxes are set to False and the formatting is lost.

Selecting another record from the master grid then selecting the original record resets the formatting.

The following defines the DocumentHost, RadPaneGroups and RadPanes;

<telerik:RadDocking Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Name="rdContent"
    Margin="5,2"
    MaxWidth="5000"
    MaxHeight="5000"
    telerik:StyleManager.Theme="Office_Blue">
     
    <telerik:RadDocking.DocumentHost>
        <telerik:RadSplitContainer x:Name="rcsContent" InitialPosition="DockedLeft">
            <telerik:RadPaneGroup x:Name="rpgContent">
                <telerik:RadPane x:Name="rpProcesses" Header="Well Processes">
                    <telerik:RadGridView Name="gvProcesses" RowStyle="{StaticResource SelectedGrid}"
                        Margin="5,2"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        telerik:StyleManager.Theme="Office_Blue"
                        AutoGenerateColumns="False"
                        ShowColumnFooters="False"
                        ShowGroupFooters="False"
                        ShowGroupPanel="False"
                        RowIndicatorVisibility="Collapsed"
                        ItemsSource="{Binding}"
                        DataLoadMode="Synchronous"
                        CanUserDeleteRows="False"
                        CanUserInsertRows="False"
                        ToolTip="Select the Processes associated with the Well Stage record"
                        UseLayoutRounding="True"
                        Visibility="Visible"
                        MinHeight="100"
                        MaxHeight="250">
 
                        <telerik:RadGridView.Resources>
                            <Style TargetType="ListBox">
                                <Setter Property="MaxHeight" Value="400" />
                            </Style>
                        </telerik:RadGridView.Resources>
 
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewCheckBoxColumn Header="Active" UniqueName="IsActive" DataMemberBinding="{Binding Path=IsActive}" IsReadOnly="True" Width="auto" TextAlignment="Center">
                                <telerik:GridViewCheckBoxColumn.CellStyle>
                                    <Style TargetType="telerik:GridViewCell">
                                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    </Style>
                                </telerik:GridViewCheckBoxColumn.CellStyle>
                            </telerik:GridViewCheckBoxColumn>
 
                            <telerik:GridViewDataColumn Header="Select" UniqueName="Selected" DataMemberBinding="{Binding Path=IsSelected}" IsReadOnly="False" Width="auto">
                                <telerik:GridViewDataColumn.CellStyle>
                                    <Style TargetType="telerik:GridViewCell">
                                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    </Style>
                                </telerik:GridViewDataColumn.CellStyle>
 
                                <!-- See http://www.telerik.com/help/wpf/gridview-checkbox-column-clicks.html for info on enabling single-click editing of checkboxes -->
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Path=IsSelected, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" telerik:StyleManager.Theme="Office_Blue" Click="Process_Clicked" />
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
 
                            <telerik:GridViewDataColumn Header="Process" UniqueName="Process" DataMemberBinding="{Binding Path=Process}" IsReadOnly="True" Width="auto" />
 
                            <telerik:GridViewDataColumn Header="Notes" UniqueName="Notes" IsReadOnly="True" Width="*">
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Path=Notes, Converter={StaticResource RemoveNewLine}}" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" />
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </telerik:RadPane>
                 
                <telerik:RadPane x:Name="rpRigClasses" Header="Rig Classes">
                    <telerik:RadGridView Name="gvRigClasses" RowStyle="{StaticResource SelectedGrid}"
                        Margin="5,2"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        telerik:StyleManager.Theme="Office_Blue"
                        AutoGenerateColumns="False"
                        ShowColumnFooters="False"
                        ShowGroupFooters="False"
                        ShowGroupPanel="False"
                        RowIndicatorVisibility="Collapsed"
                        ItemsSource="{Binding}"
                        DataLoadMode="Synchronous"
                        CanUserDeleteRows="False"
                        CanUserInsertRows="False"
                        ToolTip="Select a Project record to edit"
                        UseLayoutRounding="True"
                        Visibility="Visible"
                        MinHeight="100"
                        MaxHeight="250">
 
                        <telerik:RadGridView.Resources>
                            <Style TargetType="ListBox">
                                <Setter Property="MaxHeight" Value="400" />
                            </Style>
                        </telerik:RadGridView.Resources>
 
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewCheckBoxColumn Header="Active" UniqueName="IsActive" DataMemberBinding="{Binding Path=IsActive}" IsReadOnly="True" Width="auto" TextAlignment="Center">
                                <telerik:GridViewCheckBoxColumn.CellStyle>
                                    <Style TargetType="telerik:GridViewCell">
                                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    </Style>
                                </telerik:GridViewCheckBoxColumn.CellStyle>
                            </telerik:GridViewCheckBoxColumn>
 
                            <telerik:GridViewDataColumn Header="Select" UniqueName="Selected" DataMemberBinding="{Binding Path=IsSelected}" IsReadOnly="False" Width="auto">
                                <telerik:GridViewDataColumn.CellStyle>
                                    <Style TargetType="telerik:GridViewCell">
                                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    </Style>
                                </telerik:GridViewDataColumn.CellStyle>
 
                                <!-- See http://www.telerik.com/help/wpf/gridview-checkbox-column-clicks.html for info on enabling single-click editing of checkboxes -->
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Path=IsSelected, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" telerik:StyleManager.Theme="Office_Blue" Click="RigClass_Clicked" />
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
 
                            <telerik:GridViewDataColumn Header="Rig Class" UniqueName="RigClass" DataMemberBinding="{Binding Path=RigClass}" IsReadOnly="True" Width="auto" />
 
                            <telerik:GridViewDataColumn Header="Notes" UniqueName="Notes" IsReadOnly="True" Width="*">
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Path=Notes, Converter={StaticResource RemoveNewLine}}" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" />
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </telerik:RadPane>
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking.DocumentHost>
</telerik:RadDocking>

The attached shows;
  1. The initial display when a record is loaded.
  2. The screen after docking to the right.
  3. The screen after re-selecting the record.

The grid is bound to an ObservableCollection so I'm not sure why the "Selected" values would change.

Does anyone have any suggestions?

2 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 07 Apr 2014, 08:27 AM
Hello Raymond,

Actually, this is the expected behavior. When the Pane is dragged GridView gets unloaded and then loaded again. Please try the approach from this forum thread and let me know if it works for you.


Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Raymond
Top achievements
Rank 1
answered on 04 May 2014, 11:21 PM
Hi Yoan,

Sorry to take so long in getting back to you on this - I have been working on some other aspects of the code.

Setting the DataContext to the RadPane rather than the GridView appears to have corrected the problem.

Thanks for your help...
Tags
GridView
Asked by
Raymond
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Raymond
Top achievements
Rank 1
Share this question
or