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

RowDetails not updating

3 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 29 Dec 2011, 09:15 PM
I have a RadGridView that displays data from my database.  I have set up a DataTemplate for the RowDetails:

<DataTemplate x:Key="ReadRowDetailsTemplate">
    <Grid HorizontalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
                <Label Content="Alarms for this Read:"
                     FontSize="14"
                     FontWeight="Bold"
                     Grid.Column="0"
                     Grid.Row="0"
                     HorizontalAlignment="Center" />
                    <DataGrid AlternatingRowBackground="{DynamicResource AlternatingRowBackground}" 
                           AutoGenerateColumns="False" 
                           CanUserResizeColumns="True" 
                           CanUserSortColumns="False"
                           FontSize="14" 
                           FontWeight="Bold"
                           Grid.Column="0"
                           Grid.Row="1"
                           HorizontalAlignment="Center"
                           IsReadOnly="True"
                           ItemsSource="{Binding Path=Alarms, Mode=TwoWay}"
                           Margin="5" 
                           Name="AlarmsGrid" 
                           ScrollViewer.CanContentScroll="True"
                           ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                           ScrollViewer.VerticalScrollBarVisibility="Auto"
                           SelectionChanged="AlarmsGrid_SelectionChanged"
                           SelectionMode="Single"
                           SelectionUnit="FullRow"
                           VerticalAlignment="Top">
                    <DataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding Path=AlarmClass}"
                                            Header="Alarm Class" />
                        <DataGridTextColumn Binding="{Binding Path=AlarmTime, Converter={StaticResource DateConverter}}"
                                            Header="Time"
                                            Width="150" />
                        <DataGridTextColumn Binding="{Binding Path=ListName}"
                                            Header="Source" />
                        <DataGridTextColumn Binding="{Binding Path=AlarmStatus}"
                                            Header="Alarm Status"/>
                        <DataGridTextColumn Binding="{Binding Path=AlarmRejectedReason}"
                                            Header="Reason" />
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </DataTemplate>
In order to speed loading of the data, I have implemented the following:

  1. I have implemented a class called CustomGridViewToggleRowDetailsColumn which descends from GridViewBoundColumnBase.  This class has properties that allow me to hide the GridViewToggleButton for a row if that row does not have any row details.  It also has a Click event that is raised whenever the user clicks on the GridViewToggleButton.
  2. In my class that populates the rows of the RadGridView, I have implemented INotifyPropertyChanged.
  3. In the window that has the RadGridView, I retrieve my data from the database but leave the Alarms property (which is bound to the DataGrid's ItemsSource property in the DataTemplate) set to null initially.  A bool property called HasAlarms is set to true if the row has Alarms associated with it.
  4. In the window that has the RadGridView, I have a Click event handler for the custom Click event I mentioned in #1.  This checks to see if the Alarms property for the row that was clicked is null.  If it is, it goes to the database and retrieves the Alarms.  Note that this event can't happen unless HasAlarms is set to true for that row.

This is all working, but the DataGrid remains empty after the RowDetails are displayed.  What am I missing to make this work?

Tony

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 30 Dec 2011, 09:38 AM
Hello,

The only possible reason for which the DataGrid (developed by Microsoft by the way) remains empty is because there is no data in the Alarms collection.

Please, make sure that you have some data in this Alarms property. 

I have attached a sample project that demonstrates how row details work correctly. When a Club has Players they will be displayed correctly.

You can learn more about row details here.

Kind regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tony
Top achievements
Rank 1
answered on 04 May 2012, 01:22 PM
The Alarms property starts out as null, but the Click event handler loads them into the Alarms property from the database.   When the Alarms property is set, the PropertyChanged event is raised.  The data is there after the click, yet the details do not render.

How do I get the RadGridView to generate the row details after the Alarms property has been set, if raising the PropertyChanged event doesn't do it?  I'm trying to virtualize the loading of the Alarms data from the database and speed up the process by retrieving less data initially.

Tony
0
Tony
Top achievements
Rank 1
answered on 08 May 2012, 01:53 AM
Nevermind.  It turns out that I had to redesign the display of the data in this particular control and the code for retrieving it and the row details are no longer needed.

Thanks anyway

Tony
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Tony
Top achievements
Rank 1
Share this question
or