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

TreeListView using DataTable Project

2 Answers 77 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 31 Mar 2011, 01:54 AM
Hi,

I want to use TreeListView and use DataTable object from the datatable Project provided by telerik .
I want to have nested items that means 1 parent can have multiple childs.If i am binding with datatable currently it is showing all items in individual row.
How to achieve parent child kind of relationship using datatable object.
Please suggest.

Regards,
Rajesh

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 31 Mar 2011, 07:29 AM
Hi,

 You need to have your child data in some of the table columns and assign child table binding to this column.

All the best,
Vlad
the Telerik team
0
Rajesh
Top achievements
Rank 1
answered on 31 Mar 2011, 05:27 PM

Dear Vlad,

I tried using the way you have suggested but somehow it didnot work for me.
Below is the code snippet.

 

 

 

 

DataTable dt = new DataTable();

 

 

dt.Columns.Add(

 

new DataColumn() { ColumnName = "col1", DataType = typeof(string) });

 

 

dt.Columns.Add(

 

new DataColumn() { ColumnName = "col2", DataType = typeof(DataTable) });

 

 

 

 

DataRow dr = dt.NewRow();

 

 

dr[

 

"col1"] = "34563456";

 

 

 

 

dt.Rows.Add(dr);

 

 

 

 

 

DataTable dt1 = new DataTable();

 

 

dt1.Columns.Add(

 

new DataColumn() { ColumnName = "col1", DataType = typeof(string) });

 

 

dt1.Columns.Add(

 

new DataColumn() { ColumnName = "col2", DataType = typeof(DataTable) });

 

 

 

 

 


DataRow
dr1 = dt1.NewRow();

 

 

dr1[

 

"col1"] = "34563456";

 

dr[

 

"col2"] = dt1;

 

 

 

 

 

 

RadTreeListView1.ItemsSource = dt;

 

 

TreeListViewTableDefinition tb = new TreeListViewTableDefinition();

 

 

tb.ItemsSource =

 

new Binding("col2");

 

 

RadTreeListView1.ChildTableDefinitions.Add(tb);

Let me know if i am doing any thing wrong here.

Tags
TreeListView
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rajesh
Top achievements
Rank 1
Share this question
or