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

Drag'n'drop from ListView to singlebinded OrgChart

1 Answer 25 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 1
Morten asked on 17 Oct 2013, 11:43 AM
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");
                    break;
                }
                employees.Rows.Add(new string[] { emloyeeId, node.ID, newText, imageUrl });
            }


1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 21 Oct 2013, 04:15 PM
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.


Regards,
Peter Filipov
Telerik
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.
Tags
OrgChart
Asked by
Morten
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question
or