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

Drag&Drop to scheduler, node_Drop event not fire

1 Answer 62 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matteo Beretta
Top achievements
Rank 1
Matteo Beretta asked on 23 Aug 2010, 04:06 PM

i trying to drag a node to radscheduler, but the event node_Drop not fire, post some code:

<telerik:RadScheduler ID="radGantt" runat="server"
                            DataDescriptionField="Subject" DataEndField="End" DataKeyField="ID" 
                            DataSourceID="ObjectDataSource1" DataStartField="Start" Height="650px" Width="500px"
                            DataSubjectField="Subject" SelectedView="WeekView" FirstDayOfWeek="Monday" 
                            ShowAllDayRow="False" ShowFooter="False" 
                            ShowViewTabs="False" WorkDayEndTime="19:00:00" 
                            DayEndTime="19:00:00" Skin="Office2007" 
                            onnavigationcomplete="radGantt_NavigationComplete" 
                            onappointmentdelete="radGantt_AppointmentDelete" 
                            onappointmentupdate="radGantt_AppointmentUpdate" 
                            onappointmentcontextmenuitemclicked="radGantt_AppointmentContextMenuItemClicked">
                             <AppointmentContextMenus>
                                <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">
                                    <Items>
                                        <telerik:RadMenuItem Text="Visualizza ODL" Value="ODL" />
                                        <telerik:RadMenuItem Text="Visualizza Richiesta" Value="REQ" />
                                        <telerik:RadMenuItem Text="Rapportino" Value="RAP" />
                                    </Items>
                                </telerik:RadSchedulerContextMenu>
                            </AppointmentContextMenus>
                    </telerik:RadScheduler>
  
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        SelectMethod="AllData" TypeName="FinitenessEVO.AppointmentList">
                    </asp:ObjectDataSource>
<telerik:RadTreeView runat="server" ID="radTree" Height="100%" Width="100%" 
                                 EnableDragAndDrop="True" OnClientNodeDropping="nodeDropping"
                                 oncontextmenuitemclick="radTree_ContextMenuItemClick"
                                 onnodedrop="radTree_NodeDrop" >
                       <CollapseAnimation Duration="100" Type="OutQuint" />
                       <ContextMenus>
                           <telerik:RadTreeViewContextMenu ID="contextTree" runat="server">
                               <Items>
                                   <telerik:RadMenuItem runat="server" Text="Visualizza ODL" Value="ODL">
                                   </telerik:RadMenuItem>
                                   <telerik:RadMenuItem runat="server" Text="Visualizza Richiesta" Value="REQ">
                                   </telerik:RadMenuItem>
                               </Items>
                           </telerik:RadTreeViewContextMenu>
                       </ContextMenus>
             <ExpandAnimation Duration="100" />
         </telerik:RadTreeView>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
  
        <script type="text/javascript">
  
            function nodeDropping(sender, eventArgs) {
                // Fired when the user drops a TreeView node
                var node = eventArgs.get_sourceNode();
                var text = node.get_text();
                var htmlElement = eventArgs.get_htmlElement();
                var scheduler = $find('<%= radGantt.ClientID %>');
  
                if (isPartOfSchedulerAppointmentArea(htmlElement)) {
                    // The node 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.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 if ($telerik.isDescendant(treeViewElement, htmlElement)) {
                    // The node was dropped over the TreeView
                    // The HTML needs to be set in order for the postback to execute normally
                    eventArgs.set_destinationHtmlElement(treeViewElement);
                }
                else {
                    // The node was dropped elsewhere on the document
                    eventArgs.set_cancel(true);
                }
            }
            function rowDropping(sender, eventArgs) {
                // Fired when the user drops a grid row
                var htmlElement = eventArgs.get_destinationHtmlElement();
                var scheduler = $find('<%= radGantt.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.ClientID %>').value = timeSlot.get_index();
  
                    // The HTML needs to be set in order for the postback to execute normally
                    eventArgs.set_destinationHtmlElement("TargetSlotHiddenField.ClientID");
                }
                else {
                    // The node was dropped elsewhere on the document
                    eventArgs.set_cancel(true);
                }
            }
  
            function isPartOfSchedulerAppointmentArea(htmlElement) {
                // Determines if an html element is part of the scheduler appointment area
                // This can be either the rsContent or the rsAllDay div (in day and week view)
                return $telerik.$(htmlElement).parents().is("div.rsAllDay") ||
                            $telerik.$(htmlElement).parents().is("div.rsContent")
            }
  
            function onRowDoubleClick(sender, args) {
                sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
            }
  
            function refreshGrid() {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
            }  
  
        </script>
  
    </telerik:RadScriptBlock>
                    <input type="hidden" runat="server" id="TargetSlotHiddenField" />

1 Answer, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 24 Aug 2010, 10:36 AM
Hello Matteo Beretta,

I am sending you a working implementation of this drag-and-drop approach. Please compare your code to that in the project to see if you can find any differences that might lead you to the cause of the issue.

Sincerely yours,
Simon
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
Matteo Beretta
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or