Gridview - Adding a third hierarchy or level

4 posts, 0 answers
  1. Gonzalo
    Gonzalo avatar
    76 posts
    Member since:
    Oct 2012

    Posted 01 Mar 2012 Link to this post

    Greetings,

    How would I add a 3rd. level hierarchy programmatically? Could you provide a small example or example 511493?

    +row 1
    +child row 1
    + child row 2

    Best regards,

    G

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 Mar 2012 Link to this post

    Hello,

    Yes, you can add additional levels. You will need to simply add a new template and relation to the child template in the same way as you would add one to the master template.

    An example depends on how you wish to bind or add your data. Please have a look at the help topic which will guide you in doing this. Hope this helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Gonzalo
    Gonzalo avatar
    76 posts
    Member since:
    Oct 2012

    Posted 02 Mar 2012 Link to this post

    Thanks for you reply

    I am programatically building the tables and relationships

    Dim ID As New GridViewDecimalColumn()
    ID.Name = "ID"
    ID.HeaderText = "Id"
    RadGridView1.MasterTemplate.Columns.Add(ID)
     
    Dim Name As New GridViewTextBoxColumn()
    Name.Name = "Name"
    Name.HeaderText = "Name"
    Name.Width = 100
    RadGridView1.MasterTemplate.Columns.Add(Name)
     
    Dim Under_Appeal As New GridViewCheckBoxColumn()
    Under_Appeal.DataType = GetType(Boolean)
    Under_Appeal.Name = "Under_Appeal"
    Under_Appeal.HeaderText = "Under Appeal"
    RadGridView1.MasterTemplate.Columns.Add(Under_Appeal)
     
    Dim Terminated As New GridViewCheckBoxColumn()
    Terminated.DataType = GetType(Boolean)
    Terminated.Name = "Terminated"
    Terminated.HeaderText = "Terminated"
    RadGridView1.MasterTemplate.Columns.Add(Terminated)
     
    Dim Hash As New GridViewDecimalColumn()
    Hash.Name = "Hash"
    Hash.HeaderText = "#"
    RadGridView1.MasterTemplate.Columns.Add(Hash)
     
     
    RadGridView1.Rows.Add(1, "John", True, True)
    RadGridView1.Rows.Add(2, "Mary", True, False)
    RadGridView1.Rows.Add(3, "Peter", False, True)
     
     
    Dim template As New GridViewTemplate
    template.Columns.Add(New GridViewDecimalColumn("ParentID"))
    template.Columns.Add(New GridViewTextBoxColumn("TEXT"))
    template.Columns.Add(New GridViewDecimalColumn("PRICE"))
     
    RadGridView1.MasterTemplate.Templates.Add(template)
     
    Dim relation As New GridViewRelation(RadGridView1.MasterTemplate)
    relation.ChildTemplate = template
    relation.RelationName = "PersonProduct"
    relation.ParentColumnNames.Add("ID")
    relation.ChildColumnNames.Add("ParentID")
    RadGridView1.Relations.Add(relation)
     
     
    template.Rows.Add(1, "sugar", 2.0)
    template.Rows.Add(1, "cake", 12.0)
    template.Rows.Add(1, "butter", 3.0)
    template.Rows.Add(2, "cake", 12.0)
     
     
    Dim template2 As New GridViewTemplate
    template2.Columns.Add(New GridViewDecimalColumn("ParentID2"))
    template2.Columns.Add(New GridViewTextBoxColumn("TYPE"))
    template2.Columns.Add(New GridViewDecimalColumn("QTY"))
     
    RadGridView1.MasterTemplate.Templates(0).Templates.Add(template2)
     
    Dim relation2 As New GridViewRelation(RadGridView1.MasterTemplate.Templates(0))
    relation2.ChildTemplate = template2
    relation2.RelationName = "PersonProduct2"
    relation2.ParentColumnNames.Add("ParentID")
    relation2.ChildColumnNames.Add("ParentID2")
    RadGridView1.Relations.Add(relation2)
     
     
    template2.Rows.Add(1, "brown", 1)
    template2.Rows.Add(1, "whiter", 3)
    template2.Rows.Add(2, "banana", 2)
    I am getting errors at runtime when I try to see the 3rd level in the hyerarchy. This is just a test. 
    Best regards,

    G









  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 Mar 2012 Link to this post

    Hello Gonzalo,

    We found some issues with building hierarchy mode in unbound mode using your scenario. The issue is logged in our Public Issue Tracking System. It will be addressed in Q1 2012 SP1 release, planned for mid-March. Currently, you can use DataTable to prepare your data and build hierarchy in bound mode.

    For examples of bound hierarchy, please open our Demo application, which can be found in the Telerik folder in your Start Menu and navigate to RadGridView > Hierarchy

    Thank your time and cooperation. Your Telerik points have been updated.

    All the best,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top