Drag'n'drop from ListView to singlebinded OrgChart

2 posts, 0 answers
  1. Morten
    Morten avatar
    2 posts
    Member since:
    Jun 2011

    Posted 17 Oct 2013 Link to this post

    Hello there.

    I have been trying to create an organization chart very similar to the "Transfer Employee"-example, but ran into a little problem, cause I needed to change it from a grouped binding to a single binding.

    I played around with the OnClientDropping-function, but can't really twist it to fit my perpose.

    When I drag an element from the listview, to an element in the OrgChart, it should make the new element a child of the element dropped on, and the ajax-update i working like a charm, but the _getRealHierarchicalIndex seems to return 0 every time.

    function OnClientDropping(sender, args) {
        var orgChart = $find("<%= RadOrgChart1.ClientID %>");
        var itemText = args.get_sourceItem().get_text().trim();
        if (args.get_htmlElement().className.indexOf("rocItem") != -1 || $(args.get_htmlElement()).parents(".rocItem").length > 0) {
            var hierarchicalIndex = orgChart._extractNodeFromDomElement(args.get_htmlElement())._getHierarchicalIndex();
            hierarchicalIndex = orgChart._getRealHierarchicalIndex(hierarchicalIndex); //gets right index if drill down is on
            $find("<%= RadAjaxManager2.ClientID %>").ajaxRequest("drop-" + itemText + "-" + hierarchicalIndex);
        dropClue.style.display = "none";
        noDropClue.style.display = "none";

    As you can see, I have only changed the rocGroup to a rocItem, and ofcause it gives me some problems in the RadAjaxManager2_AjaxRequest, cause the ids contains ether 0 or 0:0

    Here's the start of the AjaxRequest:
    char[] seps = { '-' };
                string[] textAndIds = e.Argument.Split(seps, StringSplitOptions.None);
                char[] sep = { ':' };
                string[] stringIds = textAndIds[2].Split(sep, StringSplitOptions.RemoveEmptyEntries);
                int[] ids = new int[stringIds.Length];
                for (int i = 0; i < stringIds.Length; i++)
                    ids[i] = Int32.Parse(stringIds[i]);
                if (textAndIds[0] == "drop")
                    string newText = textAndIds[1];
                    OrgChartNode node = RadOrgChart1.GetNodeByHierarchicalIndex(ids);
                    var rows = from myRow in initialeEmployees.AsEnumerable() where myRow.Field<string>("FullName") == newText select new { values = myRow };
                    string imageUrl = "";
                    string emloyeeId = "";
                    foreach (var row in rows)
                        imageUrl = row.values.Field<string>("ImageUrl");
                        emloyeeId = row.values.Field<string>("EmployeeID");
                    employees.Rows.Add(new string[] { emloyeeId, node.ID, newText, imageUrl });

  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 21 Oct 2013 Link to this post

    Hello Morten,

    Could you debug the javascript and review what the following line returns:
    var hierarchicalIndex = orgChart._extractNodeFromDomElement(args.get_htmlElement())._getHierarchicalIndex();
    I have tested the provided code and it is working. Could you please setup a runnable sample and send it for a local test.

    Peter Filipov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top