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

Hierarchical RadGridView Slow Details Expansion

3 Answers 311 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 11 Apr 2011, 07:47 PM
Hello,

I set up a simple WPF window with two grids side-by-side: A Telerik RADGridView and a Microsoft DataGrid.  Both grids are set up with 2 levels of hierarchy (master-detail), and are bound to the same data (2 master records, each with 1000 detail records).  Both grids have one fixed-width column on the master and detail levels.

On my machine, when I expand a master row on the Microsoft grid for the first time, it takes 4 seconds to display all the details; expanding a master row on the Telerik grid for the first time takes 9 seconds to display the details.

The thing that appears to be taking a long time is rendering the detail rows -- if I limit the height of the detail grid to 200 pixels, it takes less than a second to expand a master for the first time (this is the case with both the Microsoft grid and the Telerik grid).

I reviewed the performance tips/tricks.  Is there anything else I can do to reduce the time it takes to expand a master for the first time in the RADGridView?

Any help is much appreciated!

Here is the XAML and code-behind I'm using:

<Window x:Class="MasterDetailPerformance.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Height="360" Width="760">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="369" />
            <ColumnDefinition Width="369" />
        </Grid.ColumnDefinitions>
 
        <StackPanel Grid.Column="0" Margin="10" Height="300" Width="350">
            <TextBlock Text="Telerik RADGridView:" />
            <telerik:RadGridView x:Name="TelerikMasterGrid" AutoGenerateColumns="False" ShowGroupPanel="False">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="200" />
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition />
                </telerik:RadGridView.ChildTableDefinitions>
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate>
                        <telerik:RadGridView x:Name="TelerikDetailGrid" ItemsSource="{Binding Details}" AutoGenerateColumns="False" ShowGroupPanel="False">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="200" />
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate>
            </telerik:RadGridView>
        </StackPanel>
 
        <StackPanel Grid.Column="1" Margin="10" Height="300" Width="350">
            <TextBlock Text="Microsoft DataGrid (click row to expand, ctrl-click to collapse):" />
            <DataGrid x:Name="MicrosoftMasterGrid" AutoGenerateColumns="False" RowDetailsVisibilityMode="VisibleWhenSelected">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="200" />
                </DataGrid.Columns>
                <DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <DataGrid x:Name="MicrosoftDetailsGrid" AutoGenerateColumns="False" ItemsSource="{Binding Details}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding Name}" Width="200" />
                            </DataGrid.Columns>
                        </DataGrid>
                    </DataTemplate>
                </DataGrid.RowDetailsTemplate>
            </DataGrid>
        </StackPanel>
    </Grid>
</Window>

public partial class MainWindow : Window
{
    private IList<Master> masterList = new List<Master>();
 
    public MainWindow()
    {
        InitializeComponent();
        FillMasterList();
        TelerikMasterGrid.ItemsSource = masterList;
        MicrosoftMasterGrid.ItemsSource = masterList;
    }
 
    private void FillMasterList()
    {
        for ( int index = 0; index < 2; ++index )
        {
            masterList.Add(
                new Master()
                {
                    ID = index,
                    Name = index.ToString(),
                    Details = GetDetails()
                } );
        }
    }
 
    private IList<Detail> GetDetails()
    {
        IList<Detail> details = new List<Detail>();
        for ( int index = 0; index < 1000; ++index )
        {
            details.Add( new Detail() { ID = index, Name = index.ToString() } );
        }
        return details;
    }
}
 
public class Master
{
    public int ID { get; set; }
    public string Name { get; set; }
    public IList<Detail> Details { get; set; }
}
 
public class Detail
{
    public int ID { get; set; }
    public string Name { get; set; }
}

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Apr 2011, 07:01 AM
Hi Bob,

 Indeed setting the Height will resolve these performance problems which are caused by the fact that both child grids are measured with infinity height in this case - no rows virtualization. 

Best wishes,
Vlad
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
Bob
Top achievements
Rank 1
answered on 12 Apr 2011, 06:24 PM
Hi Vlad, thanks for the quick response!

With a height set on the Telerik and Microsoft grids, there is still noticably more lag when expading master records on the Telerik grid.  I was hoping to find some setting or workaround to speed up the Telerik grid to perform better in this scenario.

Also, do you have any tips for improving performance when expanding a master record when there are combo box columns on the detail grid?

Thanks!
- Bob
0
Vlad
Telerik team
answered on 14 Apr 2011, 07:01 AM
Hello,

 We do not have special performance tips for such scenarios. Do you have performance problems in this case?

Best wishes,
Vlad
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
Tags
GridView
Asked by
Bob
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Bob
Top achievements
Rank 1
Share this question
or