Saving and reloading Layout of multi-level hierarchical RadGridView destroys Display

1 Answer 18 Views
GridView
Julian
Top achievements
Rank 1
Iron
Iron
Iron
Julian asked on 25 Mar 2025, 01:45 PM

Hi

I have a GridView with a relational hierarchy of two levels connected via two manual relations and two templates.

 


			gridViewRelation1.ChildColumnNames.Add("AktivitaetVorgang");
			gridViewRelation1.ChildTemplate = this.templateFremdeAktivitaetVorgaenge;
			gridViewRelation1.ParentTemplate = this.radGridPsz.MasterTemplate;
			gridViewRelation1.RelationName = "relationAktivitaetVorgang";

			gridViewRelation2.ChildColumnNames.Add("VorgangHandlungsBedarf");
			gridViewRelation2.ChildTemplate = this.templateFremdeVorgangHandlungsbedarfe;
			gridViewRelation2.ParentTemplate = this.templateFremdeAktivitaetVorgaenge;
			gridViewRelation2.RelationName = "relationVorgangHandlungsbedarfe";

			this.radGridPsz.Relations.AddRange(new Telerik.WinControls.UI.GridViewRelation[] {
				gridViewRelation1,
				gridViewRelation2});

The template of the second level is added to the Maintemplate, the template of the third level is added to the template of the second level.

Everything is working fine at first.

But if I save the layout of the grid and reload it after closing and opening the application again (via radGrid.SaveLayout and radGrid.LoadLayout),  there are no rows in the third level, although the datasource is the same, and they were there in the beginning.

The rows of the second level do not have childRows although the templates and relations are still there

 

 

 

 

1 Answer, 1 is accepted

Sort by
1
Nadya | Tech Support Engineer
Telerik team
answered on 25 Mar 2025, 03:12 PM

Hello, Julian,

Thank you for writing.  

It seems you hit a known issue. We already have logged a bug related to the nested hierarchy after loading the layout again. I updated the priority of this item upon receiving your request. You can track its progress, subscribe for status changes and add your comments on the following link - FIX. RadGridView - nested hierarchical levels are not loaded after LoadLayout

Please make sure that you subscribe to the item in order to get notified once any status changes occur. 

RadGridView's templates for the inner levels are recreated after loading the layout. Their DataSource is null, and the existing relations point to the old templates. Currently, the possible solution that I can suggest is to clear the relations and setup them again with the new  child template instances. 

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Julian
Top achievements
Rank 1
Iron
Iron
Iron
commented on 26 Mar 2025, 08:06 AM

Thank you.

Yes, that seems to be the same issue.

Could you give me an example what exactly should be done before and after loading the layout to make it work again?

Nadya | Tech Support Engineer
Telerik team
commented on 26 Mar 2025, 11:09 AM

Hello, Julian,

Yes, I will give you an example of how to recreate the relations after loading the saved layout. For this purpose, I am using the same example provided in the referred feedback item, and I extend the radButton2_Click event (which in this case is used to load the saved layout) with the workaround.

I posted below the extended code snippet for loading the layout. You can use this approach as a sample and adapt it to your needs according to how deep the hierarchy is on your side. In this sample, there are four child levels in the grid.

private void radButton2_Click(object sender, EventArgs e)
{
    string s = "default.xml";
    OpenFileDialog dialog = new OpenFileDialog();
    dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
    dialog.Title = "Select a xml file";
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        s = dialog.FileName;
    }
    this.radGridView1.LoadLayout(s);
    AddRelations();
}

private void AddRelations()
{
    GridViewRelation relation1 = new GridViewRelation();
    relation1.ParentTemplate = radGridView1.MasterTemplate.Templates[0];
    relation1.ChildTemplate = radGridView1.MasterTemplate.Templates[0].Templates[0];
    radGridView1.Relations.Add(relation1);

    GridViewRelation relation2 = new GridViewRelation();
    relation2.ParentTemplate = radGridView1.MasterTemplate.Templates[0].Templates[0];
    relation2.ChildTemplate = radGridView1.MasterTemplate.Templates[0].Templates[0].Templates[0];
    radGridView1.Relations.Add(relation2);

    GridViewRelation relation3 = new GridViewRelation();
    relation3.ParentTemplate = radGridView1.MasterTemplate.Templates[0].Templates[0].Templates[0];
    relation3.ChildTemplate = radGridView1.MasterTemplate.Templates[0].Templates[0].Templates[0].Templates[0];
    radGridView1.Relations.Add(relation3);

    radGridView1.DataSource = dt;
    radGridView1.MasterTemplate.Templates[0].Templates[0].DataSource = GetData(20, 40, 5, 20);
    radGridView1.MasterTemplate.Templates[0].Templates[0].Templates[0].DataSource = GetData(40, 100, 20, 40);
}

I hope this example helps. If you have any other questions, do not hesitate to contact me.

Julian
Top achievements
Rank 1
Iron
Iron
Iron
commented on 26 Mar 2025, 12:49 PM

Thank you very much, it is working now
Tags
GridView
Asked by
Julian
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or