Home Forums WinForms controls Xceed Grid for WinForms Hierarchical representation of data

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15720 |

    Hello,

    I have an Oracle hierarchical query (connect by prior) that returns data organized in levels that can have distinct number of branches.

    Data is in a datatable with this datarows:

    A | B | C | D | E
    | 10 | Avenida de Portugal |
    10 | 1010 | Sentido Entrada |
    1010 | 101010 | Tramo 05FT10-03FT50 | 05FT10-03FT50_4D_F | EP021
    1010 | 101020 | Tramo 03FT50-03FT32 | 03FT50-03FT32_2D_F | EP022
    1010 | 101020 | Tramo 03FT50-03FT32 | 13NL20-14NL22_3D_F | EP005
    1010 | 101020 | Tramo 03FT50-03FT32 | 14VE03-14VE24_2D_F | EP004
    1010 | 101020 | Tramo 03FT50-03FT32 | 14XL35-13XL30_3D | EP020
    1010 | 101030 | Tramo 03FT32-03FT01
    10 | 1020 | Sentido Salida
    1020 | 102010 | Tramo 03FL36-03FL52
    1020 | 102020 | Tramo 03FL52-04FL72
    1020 | 102030 | Tramo 04FL72-05FL07
    | 20 | By-Pass
    10 | 2010 | Tramo 09NC10-09NC56

    The hierarchy is between column B (the node) and A (the father of B). I need the branches be columns A, B and C (wich can have the same father) an the data asociated to the branch be columns D and E (that can be empty).

    I want to know if there is a fast way to show this kind of data in an Xceed grid. If so, can you bring me the code to do that (Visual .NET C#)?.

    Thanks.

    Imported from legacy forums. Posted by Javier (had 6674 views)

    Xceed Support
    Member
    Post count: 5658

    I’m not sure to completely understand; You want to create a master / detail grid with 3 levels?

    We can abstract the fact that it is a Oracle database. You need to create a dataset with the relations between those 3 tables.

    Here is a snippet of code that shows how to bind your dataset to GridControl:

    <code>
    gridControl1.BeginInit();

    gridControl1.SetDataBindings( dataSet1, “mainTable” );

    DetailGrid detailGrid1 = new DetailGrid();
    detailGrid1.SetDataBindings( dataSet1, “mainTable.RelationNameBetweenMainAndFirstChildTable” );
    gridControl1.DetailGridTemplates.Add( detailGrid1 );

    DetailGrid detailGrid2 = new DetailGrid();
    detailGrid2.SetDataBindings( dataSet1, “mainTable.RelationNameBetweenMainAndFirstChildTable.RelationNameBetweenFirstChildTableAndSecondChildTable” );
    detailGrid1.DetailGridTemplates.Add( detailGrid2);

    DetailGrid detailGrid3 = new DetailGrid();
    detailGrid3.SetDataBindings( dataSet1, “mainTable.RelationNameBetweenMainAndFirstChildTable.RelationNameBetweenFirstChildTableAndSecondChildTable.RelationNameBetweenSecondChildTableAndThirdChildTable” );
    detailGrid2.DetailGridTemplates.Add( detailGrid3);

    gridControl1.UpdateDetailGrids();

    gridControl1.EndInit();
    </code>

    You can also take a look at our samples, we have some that illustrate well the Master / Detail subject. You can also look at our <a href=”http://doc.xceedsoft.com/products/Xceedgrid/Overview_-_Editing.html”>Providing Data</a> topic in our help section.

    Imported from legacy forums. Posted by CharlesB (had 245 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for your response Charles.

    What i need is not a master/detail grid because i only have a dataset that gives me several branches of data with diferent number of subelements or sublevels on each.

    So, i don´t have relations between tables, i have a father/son relation with records on the same dataset, and i don’t know what is the nesting level that i can reach, because data can change it’s relationship in each query to the database by means of filters.

    Yes, it’s an Oracle database but it doesn’t matter.

    Thanks.

    Imported from legacy forums. Posted by Javier (had 495 views)

    Xceed Support
    Member
    Post count: 5658

    In this case, Un-Synchronize your DetailGrids.

    gridControl1.SynchronizeDetailGrids = false;

    And after, you could add your DataSource (a different one) to each DetailGrid.

    Imported from legacy forums. Posted by CharlesB (had 302 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Charles.

    The problem is that i don’t know in advance how many datasets i must create because the nesting level is unknown. I have only a dataset that i read record by record an must assing that data to a subdetail grid or create a new subdetail in function of record fields. That is, i must create the subdetail grids as needed.

    I have seen the MasterDetailGrid samples with unbound data that uses SynchronizeDetailGrid = false and that are a part of the solution, but i’m not able to programmatically create a detailgrid of the current row and then add the corresponding datarow to it. Can you help me with that code?

    Many thanks.

    Imported from legacy forums. Posted by luis (had 346 views)

    User (Old forums)
    Member
    Post count: 23064

    Sorry Charles. This and the last post were made by JSoler. I’m using a different computer and username.

    Imported from legacy forums. Posted by luis (had 344 views)

    Xceed Support
    Member
    Post count: 5658

    You cannot add a DetailGrid to only one DataRow. When adding a DetailGrid, you need to add it to all the DataRows.

    To simulate this behavior, you could add an empty DetailGrid to all the DataRows and de-Synchronize the DetailGrids:

    <code>
    gridControl1.SynchronizeDetailGrids = false;
    DetailGrid detail = new DetailGrid();
    gridControl1.DetailGridTemplates.Add( detail );
    </code>

    And after, you can add specific content to each of the DetailGrids:

    <code>
    DataTable dt = new DataTable();
    //Fill the DataTable
    ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).DetailGrids[ 0 ].HeaderRows.Add( new ColumnManagerRow() );
    ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).DetailGrids[ 0 ].DataSource = dt;
    </code>

    Imported from legacy forums. Posted by CharlesB (had 445 views)

    User (Old forums)
    Member
    Post count: 23064

    Charles,
    I have a question relating to similar scenario. If the nesting level is deeper, say 3-level in all, is there a way to de-synchronize the child detail grids? I don’t see a “SynchronizeDetailGrids” method on DetailGrid class.

    All pointers appreciated.
    –Anshu

    Imported from legacy forums. Posted by Anshu (had 542 views)

    Xceed Support
    Member
    Post count: 5658

    If you use the SynchronizeDetailGrids property of the GridControl, it will affect all the child grid, from all the levels. If you set this property to false, they will all be de-synchronize.

    e.g.,
    gridControl1.SynchronizeDetailGrids = false;

    Imported from legacy forums. Posted by CharlesB (had 224 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,
    How to fill the grid.Net programmatically without DataSet, and contain sub details. thanks

    Imported from legacy forums. Posted by Lovzan (had 502 views)

    Xceed Support
    Member
    Post count: 5658

    You need to do it as you would with an Unbound grid.

    You can consult this <a href=”http://doc.xceedsoft.com/products/Xceedgrid/Building_an_unbound_hierarchical_master_detail_grid.html”>Topic</a&gt;.

    Imported from legacy forums. Posted by CharlesB (had 7627 views)

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.