Hello! I am trying to upload a beam from a recursive table with the following fields:
ID; NAME; ID_FK; TYPE;
1; CARLOS NULL 0
2; PETER NULL 0
3; JHON 1 1
4; MARY 1 1
Now I would like it to be loaded according to the relationship, how could I do it?
PrivateFunction GetTreeData() As DataTable
Dim dt AsNew DataTable()
Dim dc AsNew DataColumn()
dc.ColumnName = "_ID"
dc.DataType = GetType(Integer)
dt.Columns.Add(dc)
Dim dc1 AsNew DataColumn()
dc1.ColumnName = "_Name"
dc1.DataType = GetType(String)
dt.Columns.Add(dc1)
Dim dc2 AsNew DataColumn()
dc2.ColumnName = "_ParentID"
dc2.DataType = GetType(Integer)
dt.Columns.Add(dc2)
Dim dr As DataRow
Dim SqlClass AsNew SQLSERVER 'User defined Class to fetch data from DBDim Reader = SqlClass.selectData("Select * from tbl_GroupCategory")
If Reader IsNotNothingThenWith Reader
If .HasRows ThenWhile .Read
dr = dt.NewRow()
dr(0) = .Item("_ID")
dr(1) = .Item("_Name").ToString
dr(2) = .Item("_ParentID")
dt.Rows.Add(dr)
EndWhileEndIfEndWithEndIfReturn dt
EndFunction
Considering the provided information it seems that you need to bind RadTreeView based on a parent-child relationship. In this case, I could suggest binding to self-reference data where you should set the ParentMember and ChildMember properties to the respective fields in the data source. Please refer to the following documentation article where a similar approach is described: https://docs.telerik.com/devtools/winforms/controls/treeview/data-binding/binding-to-self-referencing-data
@ Arun, thank you for your suggestion.
I hope this information helps. Should you have further questions do not hesitate to contact us.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.