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

NodeDrop not firing

5 Answers 117 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 2
Justin asked on 27 Feb 2012, 10:08 PM
I have an orgchart inside of a content place holder for a page with a master page:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadOrgChart ID="RadOrgChart1" runat="server" EnableCollapsing="true" EnableDragAndDrop="true">
    </telerik:RadOrgChart>
</asp:Content>

The data I'm using to populate the orgchart is coming from a web service - so on page load I attach the nodedrop event handler, grab the resource data which I then translate into a data table, then I do my data binding:

protected void Page_Load(object sender, EventArgs e)
    {
        RadOrgChart1.NodeDrop += RadOrgChart1_NodeDrop;
        GetResources();
        LoadEmployees();
 
        RadOrgChart1.RenderedFields.ItemFields.Add(new Telerik.Web.UI.OrgChartRenderedField() { DataField = "Position" });
 
        RadOrgChart1.DataSource = employees;
        RadOrgChart1.DataFieldID = "EmployeeID";
        RadOrgChart1.DataFieldParentID = "ReportsTo";
        RadOrgChart1.DataTextField = "FullName";
        RadOrgChart1.DataImageUrlField = "ImageUrl";
        RadOrgChart1.DataBind();
    }

The orgchart loads as expected and looks great.  When I drag and drop an item and set up break points, the page load events are hit but not the nodedrop events.  I'm not sure if there is something special I have to deal with due to the master page or if I'm just missing something basic in the page life cycle.  The way I'm looking at this I'm essentially doing it exactly as the demo suggests:  http://demos.telerik.com/aspnet-ajax/orgchart/examples/draganddropsimplebinding/defaultcs.aspx 

One additional piece of information is that the script manager is located on the master page - not sure why that should cause a problem.

5 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 01 Mar 2012, 05:00 PM
Hi Vol,

I created a sample project and reproduced the described issue. The fix will be available next week in our latest internal build. For now I prepared a workaround for you -  please review the attachment.
The problematic behavior is caused by submitting the page with EventTarget, which set to ClientID of the RadOrgChart control. To fire the RaisePostBackEvent (in particular NodeDrop event) of the control,  the EventTarget should be set to the UniqueID of the RadOrgChart.

Your points have been updated for the report.

Regards,
Peter Filipov
the Telerik team
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 their blog feed now.
0
Justin
Top achievements
Rank 2
answered on 01 Mar 2012, 11:06 PM
Thanks for the work around Peter, did the trick.
0
Ahmad
Top achievements
Rank 1
answered on 20 Mar 2012, 07:33 PM
Hi I am running into exact same problem but the solution provided is not working. I downloaded  the latest internal build but it seems like the issue is still not fixed (File Version: 2012.1.320.40). Script manager is in master page.

I tried both roc.ClientID and roc.UniqueID. Postback does happen but does not fire the NodeDrop event.

This is what I have:
CS:
            roc.DataTextField = "Name";
            roc.DataFieldID = "Id";
            roc.DataFieldParentID = "ReportsToId";
            roc.DataBind();
            this.roc.NodeDrop += new OrgChartNodeDropEventHandler(roc_NodeDrop);

//I added this as your example suggests.
            var scriptManager = Page.ClientScript;
            scriptManager.RegisterClientScriptBlock(this.GetType(), "key", "var _uniqueID = '" + roc.ClientID + "';", true);


ASPX:
<telerik:RadOrgChart runat="server" ID="roc" EnableDragAndDrop="true" EnableCollapsing="true">
            <ItemTemplate>I have a template here...</ItemTemplate>
</telerik:RadOrgChart>
<script type="text/javascript">

            Telerik.Web.UI.RadOrgChart.prototype.postback = function (postBackArgs) {

                var serializedArguments = Sys.Serialization.JavaScriptSerializer.serialize(postBackArgs);
//                alert(serializedArguments.toString());
                __doPostBack(_uniqueID, serializedArguments.toString());
            };
    
    </script>

Thanks.
0
Peter Filipov
Telerik team
answered on 21 Mar 2012, 12:27 PM
Hi Ahmad,

I tested the drag and drop functionality with version 2012.2.320.40 and everything works fine (there is no need to apply the workaround).

I created a sample project from the provided code and found out what is causing the incorrect behaviour. In the following line you pass the client ID of the RadOrgChart, it should be the unique ID:

scriptManager.RegisterClientScriptBlock(this.GetType(), "key", "var _uniqueID = '" + roc.ClientID + "';", true);

The correct one is:

scriptManager.RegisterClientScriptBlock(this.GetType(), "key", "var _uniqueID = '" + roc.UniqueID+ "';", true);


Regards,
Peter Filipov
the Telerik team
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 their blog feed now.
0
Ahmad
Top achievements
Rank 1
answered on 22 Mar 2012, 12:49 PM
Thanks, I got it to work.
Tags
OrgChart
Asked by
Justin
Top achievements
Rank 2
Answers by
Peter Filipov
Telerik team
Justin
Top achievements
Rank 2
Ahmad
Top achievements
Rank 1
Share this question
or