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

Gridview - Adding a third hierarchy or level

3 Answers 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gonzalo
Top achievements
Rank 2
Gonzalo asked on 01 Mar 2012, 04:42 PM
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

3 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 02 Mar 2012, 04:50 PM
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
0
Gonzalo
Top achievements
Rank 2
answered on 02 Mar 2012, 06:24 PM
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









0
Julian Benkov
Telerik team
answered on 07 Mar 2012, 10:08 AM
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 >>
Tags
GridView
Asked by
Gonzalo
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Gonzalo
Top achievements
Rank 2
Julian Benkov
Telerik team
Share this question
or