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

Hiearchical grid

3 Answers 131 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Miloš Sommer
Top achievements
Rank 1
Miloš Sommer asked on 01 Sep 2011, 12:38 PM

Hello,

 

I have one problem that makes me crazy. Can anyone help?

 

Problem:

I have a tree structure that I wanted to bind to RadGridView, something like this:

 

public interface IGridViewZadanka

{

    Odbornost Odbornost { get; }

    int IDZad { get; }

    string ZadankaInfo { get; }

    IEnumerable<IGridViewMetoda> MetodyView { get; }

}

 

public interface IGridViewMetoda

{

    string Test { get; }

    string Izolace { get; }

    string Postup { get; }

    string P { get; }

    string Zadani { get; }

    string Odecet { get; }

    string Vysledek { get; }

    string Stav { get; }

    bool Tisk { get; }

    string V { get; }

    string Popisek { get; }

    int IDZad { get; }

    int IDZadMet { get; }

    int? IDParent { get; }
    
Odbornost Odbornost { get; }

}

 

I want to bind this structure to two-level hierarchy grid with one feature: second level will contain 2 (or more in future) tables that depend on field Odbornost (detail table for Odbornost are slightly different – for Odbornost MB would be nice to use self-referenced hierarchy, but for Odbornost TS would be nice to use only flat view of data) and only one corresponding detail will be visible.

 

For example:

+ (IGridViewZadanka) IDZad=1, Odbornost=TS,…

   - (IGridViewMetoda) IDZad=1, Odbornost=TS,…

   - (IGridViewMetoda) IDZad=1, Odbornost=TS,…

+ (IGridViewZadanka) IDZad=1, Odbornost=MB,…

   + (IGridViewMetoda) IDZad=1, Odbornost=MB,…

      - (IGridViewMetoda) IDZad=1, Odbornost=MB,…

+ (IGridViewZadanka) IDZad=2, Odbornost=TS,…

   - (IGridViewMetoda) IDZad=2, Odbornost=TS,…

   - (IGridViewMetoda) IDZad=2, Odbornost=TS,…

 

 

From examples in http://mono.telerik.com/Grid/Examples/Hierarchy/TwoTablesAtLevel/DefaultCS.aspx and http://www.telerik.com/help/aspnet-ajax/grid-several-tables-at-level.html and http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/twotablesatlevel/defaultcs.aspx I know that this is possible, but I am unable to do it. Can anyone help me and provide me some example (in C# for win form)? I would appreciate it.

 

Misa

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Sep 2011, 11:14 AM
Hello Michaela,

Thank you for writing.

The RadGridView control for Winforms supports different type of hierarchy modes - bound, unbound, object-relational, load-on-demand, self-reference. More information about RadGridView hierarchy modes is available in our online documentation. Feel free to review it and use the most suitable variant for your application.

Do not hesitate to contact us if you need assistance with some of the modes.

Regards,
Julian Benkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Miloš Sommer
Top achievements
Rank 1
answered on 08 Sep 2011, 09:54 AM
Hello Julian,

Thank you for your reaction, but it did not solve my problem. I try to be more specific. I have 2 templates, master template and one child template and I would like to apply two relations between these templates. First relation connects data from master temlate to child template -> this works fine. Second relation would connect tree-like data from child template. Basically I need a self-reference relation on the child template, but this does not work. What have I done wrong? My code snippet follows:

Creating a child template:
// Child template settings
GridViewTemplate mikro = new GridViewTemplate();
mikro.AllowAddNewRow = false;
mikro.AllowDeleteRow = false;
mikro.EnableSorting = false;
mikro.ShowRowHeaderColumn = false;
mikro.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
  
// Add child template into MasterTemplate child collection
grid.MasterTemplate.Templates.Add(mikro);

Relations:
// Creating a hierarchy
GridViewRelation relaceMikro = new GridViewRelation(grid.MasterTemplate, mikro);
relaceMikro.RelationName = "Mikrobiologie";
relaceMikro.ParentColumnNames.Add("IDZad");
relaceMikro.ChildColumnNames.Add("IDZad");
grid.Relations.Add(relaceMikro);
// self-reference hierarchy for mikrobiology data
GridViewRelation relaceMikroSelf = new GridViewRelation(mikro, mikro);
relaceMikroSelf.RelationName = "MikrobiologieSelf";
relaceMikroSelf.ParentColumnNames.Add("IDZadMet");
relaceMikroSelf.ChildColumnNames.Add("IDParent");
grid.Relations.Add(relaceMikroSelf);

Thanks in advance,

Misa
0
Julian Benkov
Telerik team
answered on 08 Sep 2011, 03:36 PM
Hi Michaela Košutová,

Thank you for writing me back. Currently we do not support this functionality in RadGridView. The self-reference hierarchy mode can be applied only at root level. Nevertheless, I have found a work around. You should use the following code:

//add mikro2 GridViewTemplate with same columns schema and DataSource like mikro
mikro.Templates.Add(mikro2);
 
// Creating a hierarchy 
GridViewRelation relaceMikro = new GridViewRelation(grid.MasterTemplate, mikro); 
relaceMikro.RelationName = "Mikrobiologie"
relaceMikro.ParentColumnNames.Add("IDZad"); 
relaceMikro.ChildColumnNames.Add("IDZad"); 
grid.Relations.Add(relaceMikro); 
 
// self-reference hierarchy for mikrobiology data 
GridViewRelation relaceMikroSelf = new GridViewRelation(mikro, mikro2);
  
relaceMikroSelf.RelationName = "MikrobiologieSelf"
relaceMikroSelf.ParentColumnNames.Add("IDZadMet"); 
relaceMikroSelf.ChildColumnNames.Add("IDParent"); 
grid.Relations.Add(relaceMikroSelf); 

I hope this helps. If you need further assistance, I will be glad to help.

Regards,
Julian Benkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Miloš Sommer
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Miloš Sommer
Top achievements
Rank 1
Share this question
or