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

RowDetail height problem

17 Answers 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JIG
Top achievements
Rank 1
JIG asked on 22 Jun 2017, 06:08 AM

I have an issue in the gridview with the rowdetails.

 

I'm using the grid to show hierarchical data but at a certain point the rowdetails stop expanding although i have still have a gridview left with no data in it.

Why is this happening and how can i solve this so i expands and activates the scrollbars when i reaches the bottom of the grid?

17 Answers, 1 is accepted

Sort by
0
JIG
Top achievements
Rank 1
answered on 26 Jun 2017, 10:21 AM
Nobody that can help me with this issue?
0
Dinko
Telerik team
answered on 26 Jun 2017, 02:03 PM
Hello Marnix,

Thank you for contacting us.

We weren't able to reproduce this behavior. We attached to this reply the sample project we used to test your scenario. Basically, when we reach row where there is a grid with no data the rows details are expanding as expected. Can you take a look at this project and let us know if we are missing additional code from your implementation? You can also modify it to reproduce this behavior and send it back so we can further test it on our side.

We are looking forward to your reply.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
JIG
Top achievements
Rank 1
answered on 27 Jun 2017, 06:00 AM
The big difference that i noticed is that you make the datatemplates in the Xaml, i made it in code behind using reflection to set the columns and used a propertyrelation so i have no fixed datatemplate as you have.
0
JIG
Top achievements
Rank 1
answered on 28 Jun 2017, 06:17 AM

anything else i can try? looks to me like the rowdetails aren't growing beyound a certain point.

 

Could this be because of the grid/columns are being created dynamicly?

0
Dinko
Telerik team
answered on 29 Jun 2017, 01:49 PM
Hi Creonix,

There shouldn't be any difference creating grid/columns dynamically or placed in XAML. Looking at the provided code snippet I can see that you use Hierarchical GridView. I have tested your scenario by using GridViewTableDefinition and wasn't able to reproduce this behavior. You can try using Row Details instead table definition and check if this behavior still appears.

Without reproducing the problem we can only guess what could be the reason. It will be great if you can send us isolated project from your application reproducing it.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
JIG
Top achievements
Rank 1
answered on 30 Jun 2017, 06:37 AM

That's not a solution because i need to see if there are details or not.

i'll attach a file with some more details of my code maybe you can see a bit more :

//viewmodel
private void GenerateColumns()

{
CurrentView.grid.Columns.Clear();
CurrentView.grid.ChildTableDefinitions.Clear();

sublists.Add(new KeyValuePair<Type, List<MDMComboBoxItem>>(entity.GetType(), GetListForComboboxColumn(results)));

List<EntityQuery> queries = new List<EntityQuery>();

foreach (DataEntityProperty fkname in fklist)
{
NavigationEntityProperty nep = entity.EntityAspect.EntityMetadata.ScalarNavigationProperties.FirstOrDefault(np => np.Name == fkname.RelatedNavigationPropertyName);
Entity linkedEntity = _dataService.GetManager().CreateEntity(nep.DataType) as Entity;
string pkName = linkedEntity.EntityAspect.EntityMetadata.KeyProperties.FirstOrDefault().Name;

if (entity.GetType() != linkedEntity.GetType())
{
EntityQuery query = EntityQuery.Create(linkedEntity.GetType(), _dataService.GetManager());
queries.Add(query);
}
}

var coop = Coroutine.StartParallel(() => LoadListEntitiesCoroutine(queries));
coop.Completed += (sender, args) =>
{
foreach (EntityQueryOperation notif in args.Notifications)
{
List<EntityBase> resultnotifs = notif.Results.Cast<EntityBase>().ToList();
GetList(resultnotifs, resultnotifs.FirstOrDefault().GetType());
}

foreach (string name in columnNames)
{
DataEntityProperty dep = fklist.FirstOrDefault(fk => fk.Name == name);
AddColumnToGrid(new GridViewDataColumn()
{
Header = name,
DataMemberBinding = new System.Windows.Data.Binding(name),
IsVisible = ((dep == null && name != entitypk) || (dep == null && name == entitypk && ShowPK) || (dep != null && ShowRawData)),
IsReadOnly = (name == entitypk || ReadOnlyFields.Contains(name))
});

if (dep != null)
{
NavigationEntityProperty nep = entity.EntityAspect.EntityMetadata.ScalarNavigationProperties.FirstOrDefault(np => np.Name == dep.RelatedNavigationPropertyName);
Entity linkedEntity = _dataService.GetManager().CreateEntity(nep.DataType) as Entity;
string pkName = linkedEntity.EntityAspect.EntityMetadata.KeyProperties.FirstOrDefault().Name;

List<MDMComboBoxItem> cbblist = sublists.First(x => x.Key == linkedEntity.GetType()).Value;

AddColumnToGrid(new GridViewComboBoxColumn()
{
Header = name.Substring(0, name.Length - 2),
ItemsSource = cbblist,
DisplayMemberPath = "Description",
DataMemberBinding = new System.Windows.Data.Binding(name),
SelectedValueMemberPath = "ID",
EditTriggers = ReadOnlyFields.Contains(name) ? Telerik.Windows.Controls.GridView.GridViewEditTriggers.None : Telerik.Windows.Controls.GridView.GridViewEditTriggers.Default,
IsVisible = !ShowRawData
});
}
}

if (hierarchical)
{
NavigationEntityProperty navprop = entity.EntityAspect.EntityMetadata.NavigationProperties.FirstOrDefault(n => n.RelationLink.FromRole.Properties.Count() > 0 &&
n.RelationLink.FromRole.Properties[0].Name == entitypk && n.RelationLink.ToRole.Properties.Count() > 0 && n.RelationLink.ToRole.Properties[0].Name == upperKey);
childPropName = navprop.Name;
childrelation = new PropertyRelation(navprop.Name);
childrelation.IsSelfReference = true;
CurrentView.grid.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = childrelation });
}

IsBusy = false;
};
}

public void CloneParentColumns(RadGridView childGrid)
{
childGrid.ShowGroupPanel = false;
childGrid.AutoGenerateColumns = false;
childGrid.Style = CurrentView.grid.Style;
childGrid.SortDescriptors.Clear();
childGrid.SortDescriptors.AddRange(CurrentView.grid.SortDescriptors);
childGrid.SelectionChanged -= Grid_SelectionChanged;
childGrid.SelectionChanged += Grid_SelectionChanged;
childGrid.Columns.Clear();

foreach (GridViewColumn column in CurrentView.grid.Columns)
{
GridViewColumn newcolumn = null;

switch (column.GetType().Name)
{
case "GridViewDataColumn":
newcolumn = new GridViewDataColumn() { Header = column.Header, DataMemberBinding = new System.Windows.Data.Binding(column.Header.ToString()), IsVisible = column.IsVisible };
break;
case "GridViewComboBoxColumn":
newcolumn = new GridViewComboBoxColumn() { Header = column.Header, ItemsSource = ((GridViewComboBoxColumn)column).ItemsSource, DisplayMemberPath = ((GridViewComboBoxColumn)column).DisplayMemberPath, DataMemberBinding = new System.Windows.Data.Binding(column.Header.ToString() + "ID"), SelectedValueMemberPath = ((GridViewComboBoxColumn)column).SelectedValueMemberPath, EditTriggers = Telerik.Windows.Controls.GridView.GridViewEditTriggers.Default };
break;
}

childGrid.Columns.Add(newcolumn);
}
}

//grid in xaml
<telerik:RadGridView Grid.Column="2" x:Name="grid" ItemsSource="{Binding List}" AutoGenerateColumns="False" Style="{StaticResource CSD4_RadGridViewStyle}"
RowLoaded="grid_RowLoaded" DataLoading="grid_DataLoading" ShowGroupPanel="False" SelectionChanged="grid_SelectionChanged">
<telerik:RadGridView.SortDescriptors>
<telerik:SortDescriptor Member="ShortName"/>
</telerik:RadGridView.SortDescriptors>
</telerik:RadGridView>

//methods in code behind of xaml
public void EditingRowsGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
_viewModel.SaveEntity(e.Row.DataContext as EntityBase);
}

private void grid_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
GridViewDataControl dataControl = (GridViewDataControl)sender;
if (dataControl.ParentRow != null)
{
dataControl.RowLoaded += grid_RowLoaded;
dataControl.RowEditEnded += EditingRowsGrid_RowEditEnded;
_viewModel.CloneParentColumns(dataControl as RadGridView);
}
}
0
Dinko
Telerik team
answered on 04 Jul 2017, 02:31 PM
Hello Creonix,

Thank you for the provided additional code. From the code snippet, we can see that you have set the IsSelfReference property to true. Are you trying to achieve something similar like in the Self-Reference Hierarchy sample project in the desktop WPF Controls Demo? You can try setting this property to false and check again if this behavior still appears? Also, can you send us the Loaded event handler as is missing in the attached code snippet?  Looking at the provided code there is nothing suspicious which could lead to this behavior? We weren't able to create sample project based on the provided code because some of the class are missing.

Can you send us a video which shows the steps and demonstrate this behavior?

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
JIG
Top achievements
Rank 1
answered on 05 Jul 2017, 01:19 PM
What i'm trying to achieve is to load all data from 1 table in the database and show them hierachical , so if only 1 item is the topmost then that will be shown at first, and from there on keep expanding until there is nothing more to expand
0
JIG
Top achievements
Rank 1
answered on 05 Jul 2017, 01:30 PM

If i set the selfreference to false i get this, the childs are no longer showing if they have chils of there own.

 

Below i added to methods you asked for

--VIEW
private void grid_DataLoading(object sender, GridViewDataLoadingEventArgs e)

        {
            GridViewDataControl dataControl = (GridViewDataControl)sender;
            if (dataControl.ParentRow != null)
            {
                dataControl.RowLoaded += grid_RowLoaded;
                dataControl.RowEditEnded += EditingRowsGrid_RowEditEnded;
                _viewModel.CloneParentColumns(dataControl as RadGridView);
            }
        }

        private void grid_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.Row.GetType() != typeof(GridViewHeaderRow) && e.Row.GetType() != typeof(GridViewFooterRow))
            {
                ((GridViewRow)e.Row).IsExpandable = _viewModel.CanExpandRow(e.DataElement as EntityBase);
            }
        }

--VIEWMODEL
public void CloneParentColumns(RadGridView childGrid)

        {
            childGrid.ShowGroupPanel = false;
            childGrid.AutoGenerateColumns = false;
            childGrid.Style = CurrentView.grid.Style;
            childGrid.SortDescriptors.Clear();
            childGrid.SortDescriptors.AddRange(CurrentView.grid.SortDescriptors);
            childGrid.SelectionChanged -= Grid_SelectionChanged;
            childGrid.SelectionChanged += Grid_SelectionChanged;
            childGrid.Columns.Clear();

            foreach (GridViewColumn column in CurrentView.grid.Columns)
            {
                GridViewColumn newcolumn = null;

                switch (column.GetType().Name)
                {
                    case "GridViewDataColumn":
                        newcolumn = new GridViewDataColumn() { Header = column.Header, DataMemberBinding = new System.Windows.Data.Binding(column.Header.ToString()), IsVisible = column.IsVisible };
                        break;
                    case "GridViewComboBoxColumn":
                        newcolumn = new GridViewComboBoxColumn() { Header = column.Header, ItemsSource = ((GridViewComboBoxColumn)column).ItemsSource, DisplayMemberPath = ((GridViewComboBoxColumn)column).DisplayMemberPath, DataMemberBinding = new System.Windows.Data.Binding(column.Header.ToString() + "ID"), SelectedValueMemberPath = ((GridViewComboBoxColumn)column).SelectedValueMemberPath, EditTriggers = Telerik.Windows.Controls.GridView.GridViewEditTriggers.Default };
                        break;
                }

                childGrid.Columns.Add(newcolumn);
            }
        }

0
JIG
Top achievements
Rank 1
answered on 07 Jul 2017, 06:19 AM

I just tested something, if i hardcode the rowdetailstemplate the grid master row keeps expanding as it should. But this i cannot do because i don't know how many levels i have before i start and i use the grid for all sorts of table so nothing is prefedined.

So it looks to me like there is a problem when the child grids are generated when rows are expanded

0
Dinko
Telerik team
answered on 10 Jul 2017, 12:44 PM
Hi CreoniX,

We tried different ways to reproduce it but with no avail. Without reproducing it we can only guess what could be the reason behind this. In the attached code snippet you are using PropertyRelation. Can you use TableRelation and check if this behavior still exists. You can take a look at the Self-Referencing GridView help article in our documentation.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
JIG
Top achievements
Rank 1
answered on 13 Jul 2017, 01:38 PM

did you use a flat list where the items in the list have childeren that are in that list?

 

Fe list contains : A, B ,C, D, E, F -> A has childeren B and C -> B has childeren E and F, and so on?

Or did you start from a strictly hierarchical list?

0
JIG
Top achievements
Rank 1
answered on 14 Jul 2017, 07:22 AM

Did some additional investigation starting from the 'Self-Reference Hierarchy' example in the telerik UI for WPF Demos.

Instead of generating the data in code, we used a database to get our data from.

It seems there is a hardcoded maximum rowheight for each row?

 

The only code we've added is the following code in the DataLoading function as we need more then 1 hierarchical level

TableRelation r = new TableRelation();
r.IsSelfReference = true;
r.FieldNames.Add(new FieldDescriptorNamePair("LocationID", "UpperLocationID"));
dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = r });

Code Example

void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
{
    GridViewRow row = e.Row as GridViewRow;
    TblLstLocation employee = e.DataElement as TblLstLocation;
 
    if (row != null && employee != null)
    {
        row.IsExpandable = this.HasSubordinates(employee);
    }
}
 
private bool HasSubordinates(TblLstLocation employee)
{
    return
    (from emp in (IEnumerable<TblLstLocation>)this.RadGridView1.ItemsSource
     where emp.UpperLocationID == employee.LocationID
     select emp).Any();
}
 
private void RadGridView1_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
    GridViewDataControl dataControl = (GridViewDataControl)sender;
    if (dataControl.ParentRow != null)
    {
        dataControl.BorderThickness = new Thickness(0, 1, 0, 1);
        dataControl.GridLinesVisibility = GridLinesVisibility.None;
        dataControl.ShowGroupPanel = false;
        dataControl.AutoGenerateColumns = true;
        dataControl.CanUserFreezeColumns = false;
        dataControl.IsReadOnly = true;
        dataControl.ChildTableDefinitions.Clear();
 
        TableRelation r = new TableRelation();
        r.IsSelfReference = true;
        r.FieldNames.Add(new FieldDescriptorNamePair("LocationID", "UpperLocationID"));
        dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = r });
 
        //GridViewDataColumn column = new GridViewDataColumn();
        //column.DataMemberBinding = new Binding("EmployeeID");
        //dataControl.Columns.Add(column);
 
        //column = new GridViewDataColumn();
        //column.DataMemberBinding = new Binding("FirstName");
        //dataControl.Columns.Add(column);
 
        //column = new GridViewDataColumn();
        //column.DataMemberBinding = new Binding("LastName");
        //dataControl.Columns.Add(column);
 
        //column = new GridViewDataColumn();
        //column.DataMemberBinding = new Binding("Title");
        //dataControl.Columns.Add(column);
    }
}
0
JIG
Top achievements
Rank 1
answered on 14 Jul 2017, 08:28 AM

Did the same with the telerik example;

 

Changed the following code (TableRelation) to add hierarchy in the child items.

private void RadGridView1_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
    GridViewDataControl dataControl = (GridViewDataControl) sender;
    if (dataControl.ParentRow != null)
    {
        dataControl.BorderThickness = new Thickness(0, 1, 0, 1);
        dataControl.GridLinesVisibility = GridLinesVisibility.None;
        dataControl.ShowGroupPanel = false;
        dataControl.AutoGenerateColumns = false;
        dataControl.CanUserFreezeColumns = false;
        dataControl.IsReadOnly = true;
        dataControl.ChildTableDefinitions.Clear();
 
        TableRelation r = new TableRelation();
        r.IsSelfReference = true;
        r.FieldNames.Add(new FieldDescriptorNamePair("EmployeeID", "ReportsTo"));
        dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = r });
 
 
        GridViewDataColumn column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("EmployeeID");
        dataControl.Columns.Add(column);
 
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("FirstName");
        dataControl.Columns.Add(column);
 
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("LastName");
        dataControl.Columns.Add(column);
 
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("Title");
        dataControl.Columns.Add(column);
    }
}

 

Changed some data in the example. More hierarchical levels. Even in this example the row is adding a scrollviewer after a specific height.

 

 

0
Accepted
Dinko
Telerik team
answered on 18 Jul 2017, 11:03 AM
Hi Marnix Catteeuw,

You are right that there is max height. The maximum height is set to the RadGridView itself. In order, the UI virtualization of the RadGridView to work the MaxHeight property need to be set. In your case, you can set the MaxHeight property to a bigger value. The default one is 300.
private void RadGridView1_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
    GridViewDataControl dataControl = (GridViewDataControl) sender;
    if (dataControl.ParentRow != null)
    {
        dataControl.BorderThickness = new Thickness(0, 1, 0, 1);
        dataControl.GridLinesVisibility = GridLinesVisibility.None;
        dataControl.ShowGroupPanel = false;
        dataControl.AutoGenerateColumns = false;
        dataControl.CanUserFreezeColumns = false;
        dataControl.IsReadOnly = true;
        dataControl.ChildTableDefinitions.Clear();
        // for example
        dataControl.MaxHeight = 1000;
         
        TableRelation r = new TableRelation();
        r.IsSelfReference = true;
        r.FieldNames.Add(new FieldDescriptorNamePair("EmployeeID", "ReportsTo"));
        dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = r });
  
  
        GridViewDataColumn column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("EmployeeID");
        dataControl.Columns.Add(column);
  
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("FirstName");
        dataControl.Columns.Add(column);
  
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("LastName");
        dataControl.Columns.Add(column);
  
        column = new GridViewDataColumn();
        column.DataMemberBinding = new Binding("Title");
        dataControl.Columns.Add(column);
    }
}

Give this approach a try and let me know if it works in your case.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
JIG
Top achievements
Rank 1
answered on 24 Jul 2017, 09:58 AM

Hi Dinko,

Thanks for the answer. This solution solved the problem.

We changed the value to      

dataControl.MaxHeight = double.MaxValue;

 

Kind regards

0
JIG
Top achievements
Rank 1
answered on 24 Jul 2017, 09:58 AM

Hi Dinko,

Thanks for the answer. This solution solved the problem.

We changed the value to      

dataControl.MaxHeight = double.MaxValue;

 

Kind regards

Tags
GridView
Asked by
JIG
Top achievements
Rank 1
Answers by
JIG
Top achievements
Rank 1
Dinko
Telerik team
Share this question
or