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

Org Chart Binding Issue - Not Visible

1 Answer 171 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
kuntesh
Top achievements
Rank 1
kuntesh asked on 06 May 2014, 06:34 AM
Hi

     I have done Programmatically Binding to the RadOrgChart with DataTable . But i am not able to see the chart on UI. Below is my Code


            DataTable table = new DataTable();
            table.Columns.Add("ID", typeof(String));
            table.Columns.Add("Title", typeof(String));
            table.Columns.Add("AndOr", typeof(String));
            table.Columns.Add("ParentID", typeof(String));
            table.Columns.Add("Designation", typeof(String));

            table.Rows.Add("1", "John Smith", "", "4", "CEO");
            table.Rows.Add("2", "Joe Robert", "Or", "1", "Manager SLS");
            table.Rows.Add("3", "Jack Kent", "Or", "1", "Manager Mkt");
            table.Rows.Add("4", "Ravi Kumar", "Or", "2", "Engineer");
            table.Rows.Add("5", "Sue Raymond", "And", "2", "Engineer");
            table.Rows.Add("6", "Lisa simpson", "Or", "4", "Junior Engineer");
            table.Rows.Add("7", "Bob Woley", "", "5", "Junior Engineer");
            table.Rows.Add("8", "Ron Jones", "", "3", "CSR");
            table.Rows.Add("9", "Dave Mason", "Or", "3", "CSR");
            table.Rows.Add("10", "John Williams", "", "3", "CSR");

            objRadOrgChart.DataTextField = "Title";
            objRadOrgChart.DataFieldID = "ID";
            objRadOrgChart.DataFieldParentID = "ParentID";      
            objRadOrgChart.DataSource = table;
            objRadOrgChart.DataBind();

             This not Shows anything on Page . But when i remove DataFieldParentID  , It shows all records with chart . Please help how it wants the data to show the chart on Page

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 May 2014, 07:10 AM
Hi kuntesh,

DataFieldParentID of RadOrgChart is holding the name of the DataColumn of ParentID value. In order to Show any node as parent you need to set the ParentId of that particular node to null and the child nodes ParentId is the Id of the ParentNode. Please do the following modification in your code which works fine at my end.

C#:
protected void Page_Load(object sender, EventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(String));
    table.Columns.Add("Title", typeof(String));
    table.Columns.Add("AndOr", typeof(String));
    table.Columns.Add("ParentID", typeof(String));
    table.Columns.Add("Designation", typeof(String));
 
    table.Rows.Add("1", "John Smith", "", null, "CEO");
    table.Rows.Add("2", "Joe Robert", "Or", "1", "Manager SLS");
    table.Rows.Add("3", "Jack Kent", "Or", "1", "Manager Mkt");
    table.Rows.Add("4", "Ravi Kumar", "Or", "2", "Engineer");
    table.Rows.Add("5", "Sue Raymond", "And", "2", "Engineer");
    table.Rows.Add("6", "Lisa simpson", "Or", "4", "Junior Engineer");
    table.Rows.Add("7", "Bob Woley", "", "5", "Junior Engineer");
    table.Rows.Add("8", "Ron Jones", "", "3", "CSR");
    table.Rows.Add("9", "Dave Mason", "Or", "3", "CSR");
    table.Rows.Add("10", "John Williams", "", "3", "CSR");
 
    RadOrgChart2.DataFieldID = "ID";
    RadOrgChart2.DataFieldParentID = "ParentID";
    RadOrgChart2.DataTextField = "Title";
    RadOrgChart2.DataSource = table;
    RadOrgChart2.DataBind();
}

Thanks,
Princy.
Tags
OrgChart
Asked by
kuntesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or