NodeDrop not firing.

4 posts, 1 answers
  1. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 08 Nov 2010 Link to this post

    I'm trying to achieve a drag from a RadTreeNode(basically a task) to a RadSchedulerTimeSlot (hence creating an appointment for that task). Now the problem is that NodeDrop is not firing when I drag the TreeNode to the RadScheduler.

    Here's what I have:-

    RadTreeView:
    <telerik:RadTreeView ID="radTreeView" runat="server" CssClass="treeView" EnableDragAndDrop="True"
        OnClientNodeDropping="rowDropping" OnNodeDrop="radTreeView_NodeDrop" Skin="Windows7">
        <Nodes>
            <telerik:RadTreeNode runat="server" Owner="radTreeView" Text="Test">
                <Nodes>
                    <telerik:RadTreeNode runat="server" Owner="" Text="Test2">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode runat="server" Owner="" Text="Test">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
            <telerik:RadTreeNode runat="server" Owner="radTreeView" Text="Test2">
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

    RadScheduler:
    <telerik:RadScheduler ID="radScheduler" runat="server" DayEndTime="19:00:00" FirstDayOfWeek="Monday"
        LastDayOfWeek="Sunday" OverflowBehavior="Expand" SelectedView="WeekView" ShowAllDayRow="False"
        ShowFooter="False" Skin="Windows7" WorkDayEndTime="19:00:00" OnClientAppointmentClick="OnClientAppointmentClick"
        OnClientTimeSlotClick="OnClientTimeSlotClick" CssClass="scheduler" ShowViewTabs="False">
        <AdvancedForm Modal="True" />
        <TimelineView UserSelectable="False" />
        <MonthView UserSelectable="False" />
    </telerik:RadScheduler>

    rowDropping Javascript:
    function rowDropping(sender, eventArgs) {
        // Fired when the user drops a grid row
        var htmlElement = eventArgs.get_htmlElement();
        var scheduler = $find('<%= radScheduler.ClientID %>');
     
        if (isPartOfSchedulerAppointmentArea(htmlElement)) {
            // The row was dropped over the scheduler appointment area
            // Find the exact time slot and save its unique index in the hidden field
            var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement);
     
            // $get("TargetSlotHiddenField").value = timeSlot.get_index();
            $get('<%= TargetSlotHiddenField.ClientID %>').value = timeSlot.get_index();
     
            // The HTML needs to be set in order for the postback to execute normally
            eventArgs.set_htmlElement('<%= TargetSlotHiddenField.ClientID %>');
        }
        else {
            // The node was dropped elsewhere on the document
            eventArgs.set_cancel(true);
        }
    }

    HiddenTextbox:
    <input type="hidden" runat="server" id="TargetSlotHiddenField" />

    CodeBehind:
    protected void radTreeView_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
        RadTreeNode treeNode = e.DraggedNodes[0];
     
        string id = treeNode.Value;
        string subject = treeNode.Text;
        string targetSlotIndex = TargetSlotHiddenField.Value;
     
        if (targetSlotIndex != string.Empty)
        {
            HandleSchedulerDrop(id, subject, targetSlotIndex);
            TargetSlotHiddenField.Value = string.Empty;
        }
    }
     
    private void HandleSchedulerDrop(string id, string subject, string targetSlotIndex)
    {
        radScheduler.Rebind();
     
        ISchedulerTimeSlot slot = radScheduler.GetTimeSlotFromIndex(targetSlotIndex);
     
        TimeSpan duration = TimeSpan.FromHours(1);
        if (slot.Duration == TimeSpan.FromDays(1))
        {
            duration = slot.Duration;
        }
     
        ScheduleTask(id, subject, slot.Start, slot.Start.Add(duration));
    }


    Most of it is stripped from your demos. If you need the rest of the code I'd be happy to supply the whole page and codebehind.

    Thanks in advance.
    Daryl
  2. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 10 Nov 2010 Link to this post

    Bump.
  3. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 11 Nov 2010 Link to this post

    Anyone?
  4. Answer
    Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 11 Nov 2010 Link to this post

    Hello Daryl,

    I am attaching a sample that you can use in order to determine what goes wrong.

    I hope this is going to help you!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top