orgchart and Root parent id

8 posts, 0 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 16 Jun 2014 Link to this post

    Hello

    When i use in the OrgChart , the business object to databinding ,it's work very well.

    But if my Root guy on the OrgChart do not Containd parent_id == 0, the orgchart doesn't work ! and doesn't appear.

    My customer use the multi level marketing (mlm) , and if the user root get a tree , it's possible his parent_id don't get a Zero in his value.

    It's possible to correct in the OrgChart

    id    parent_id
    5       4
    6       5
    7       5
    8       5

    it' should be work.

    thanks 
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 19 Jun 2014 Link to this post

    Hi Oliver,

    Such structure is invalid. The OrgChart expects to have at least one root item, where the parent_id is null.

    For example:
    id    parent_id
    5       4
    6       5
    7       5
    8       5
    4       null

    However if the data returned by your database is similar, try to put this data in some collection of objects, then replace all 0 with NULL values. Finally bound  the OrgChart to the collection with the valid data.

    DB <-> Collection <-> OrgChart

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 28 Aug 2014 Link to this post

    Hello

    Can you accept  Zero : "0" or null value in ROOT item : please ?

    I don't usually  use Null value in my database.

    thanks
    Olivier
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2014 in reply to Olivier Link to this post

    Hi Olivier,

    As far as I know this is not possible because DataFieldParentID must be null if it is of nullable (e.g. int?) or reference (e.g. string) type.

    Thanks,
    Shinu.
  6. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 29 Aug 2014 in reply to Shinu Link to this post

    Hello there

    everything is possible, in programming, if you will not start at the root node,
    Why Would not this option?
    I had to make a view to work around this big problem.

    it's not difficult to  accept any value, to start the root what we want.

    Do you understand me ?
  7. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 02 Sep 2014 Link to this post

    Hi,

    The DataFieldParentID cannot be null when the OrgChart is populated from a database. For example if you have the following table structure:

    int ID (Primary Key)
    nvarchar Text
    int ParentID (Foreign Key)

    the dababase will not allow you to enter new record, where the ParentID is 0 and if there are not record with ID=0.

    However it is possible to populate the OrgChart with the following code:

    <telerik:RadOrgChart runat="server" ID="orgChart"></telerik:RadOrgChart>

    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Item> items = new List<Item>();
            for (int i = 0; i < 3; i++)
            {
                items.Add(new Item()
                    {
                        Id = i,
                        Name = "Parent " + i.ToString(),
                        ParentID = 0
                    });
            }
     
            for (int i = 0; i < 3; i++)
            {
                items.Add(new Item()
                    {
                        Id = i,
                        Name = "Child " + i.ToString(),
                        ParentID = 1
                    });
            }
     
            orgChart.DataSource = items;
            orgChart.DataTextField = "Name";
            orgChart.DataFieldID = "Id";
            orgChart.DataFieldParentID = "ParentID";
     
            orgChart.DataBind();
        }
    }
     
    public class Item
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ParentID { get; set; }
    }


    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 02 Sep 2014 Link to this post

    on day , you ll upgrade with my tips.

    In orgChart, the null value for the parent id , is the BIG BOSS == CEO

    If we want to start with Chief Employee only , it's not possible without your difficulty code not plug and play !
  9. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 03 Sep 2014 Link to this post

    Hi Oliver,

    I'm not sure if I understood correctly what the problem is. The OrgChart can display all kind of hierarchical structures.  So if your data base is something similar to this http://screencast.com/t/J7TL8Gb8GbT
    then you should get the desired behavior. http://screencast.com/t/NtuJZlroAo

    To start with the "Chief Employee" only you can modify the select command of  your data source.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017