Hello,
Our application uses gridviews to display hierarchical data using two separate data tables that share a key for lookup purposes.
The application previously used WinControls RadGridView and joined the two tables using a GridViewRelation.
Our application uses gridviews to display hierarchical data using two separate data tables that share a key for lookup purposes.
The application previously used WinControls RadGridView and joined the two tables using a GridViewRelation.
this.Grid.BeginUpdate();
this.Grid.MasterTemplate.Reset();
Grid.DataSource = datatables[0];
if (AddDetails)
{
GridViewTemplate template = new GridViewTemplate();
template.DataSource = datatables[1];
Grid.Templates.Add(template);
GridViewRelation relation = new GridViewRelation(Grid.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "Details";
relation.ParentColumnNames.Add(PC);
relation.ChildColumnNames.Add(CC);
Grid.Relations.Add(relation);
}
Once loaded, the lookup was very fast, i.e. I could expand any row to view the child data more or less
instantly.
However when I switched over to the WPF gridview, performance for the same input became
unacceptably slow, for example it takes
approximately 2 seconds every time to expand a row to view the child data.
The WPF xaml looks like so:<Grid>
<telerik:RadGridView x:Name="BugGrid"
IsFilteringAllowed="True"
IsReadOnly="True"
CanUserInsertRows="False"
TabIndex="1"
AutoGenerateColumns="False"
DataLoading="DataLoading"
RowHeight="32"
MaxColumnWidth="200"
EnableRowVirtualization="True"
EnableColumnVirtualization="True"
DataLoadMode="Asynchronous"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding asdfas}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Blah}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding PC}" IsVisible="False"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition x:Name="Details">
<telerik:GridViewTableDefinition.Relation>
<telerik:TableRelation>
<telerik:TableRelation.FieldNames>
<telerik:FieldDescriptorNamePair
ParentFieldDescriptorName="PC"
ChildFieldDescriptorName="CC"/>
</telerik:TableRelation.FieldNames>
</telerik:TableRelation>
</telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>
</telerik:RadGridView.ChildTableDefinitions>
</telerik:RadGridView>
</Grid>
In the code behind I define the properties of the child table in DataLoading
private void DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
GridViewDataControl dataControl = (GridViewDataControl) sender;
if (dataControl.ParentRow != null)
{
dataControl.AutoGenerateColumns = false;
dataControl.ShowGroupPanel = false;
dataControl.IsFilteringAllowed = false;
dataControl.CanUserFreezeColumns = false;
dataControl.IsReadOnly = true;
GridViewDataColumn column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("CC");
column.IsVisible = false;
column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("Name");
dataControl.Columns.Add(column);
column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("Value");
dataControl.Columns.Add(column);
}
I set the data source of the child table definition to the be the data table with the details.
I've been able to determine that it's the looking up of the appropriate child data from
the data table that is the very slow part (e.g. if the details data table is blank,
the rows expand instantly) but why is it SO much slower than the old WinControls grid, which also worked with the same data using a similar Relationship.
More importantly, how can I speed it up?