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

NodeDrop not firing.

3 Answers 121 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 08 Nov 2010, 12:42 PM
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

3 Answers, 1 is accepted

Sort by
0
Alan
Top achievements
Rank 1
answered on 10 Nov 2010, 08:39 AM
Bump.
0
Alan
Top achievements
Rank 1
answered on 11 Nov 2010, 08:14 AM
Anyone?
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 11 Nov 2010, 11:42 AM
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
Tags
TreeView
Asked by
Alan
Top achievements
Rank 1
Answers by
Alan
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or