TreeListView using DataTable Project

3 posts, 0 answers
  1. Rajesh
    Rajesh avatar
    27 posts
    Member since:
    Jan 2011

    Posted 30 Mar 2011 Link to this post

    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. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 31 Mar 2011 Link to this post

    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
  3. DevCraft banner
  4. Rajesh
    Rajesh avatar
    27 posts
    Member since:
    Jan 2011

    Posted 31 Mar 2011 Link to this post

    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.

Back to Top