Home - Forums-.NET - FlyTreeView (ASP.NET) - Correct Events

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Correct Events
Link Posted: 14-Jul-2008 02:16
I have the following:


                                                    ExpandLevel="2" BorderColor="Silver" BorderWidth="1px" Height="185px" Width="280px"
                            Padding="2px" DragDropAcceptNames="treeviewnode,dragname" DragDropName="treeviewnode"
                            EnableFullRowEvents="True" OnInsertCallbackNodesFromValue="flyTreeView2_InsertCallbackNodesFromValue"
                            OnDropJavascript="flyTreeView2_OnDrop" OnDragOverJavascript="flyTreeView2_OnDragOver"
                            OnDragOutJavascript="flyTreeView2_OnDragOut" RootDragDropAcceptNames="treeviewnode,dragname"
                            FadeEffect="true">
                            
                                
                            
                                                            Padding="2px;3px;3px;1px" RowHeight="18px" />
                            
                            
                        


I populate this from a Dataset in the code behind.

What I am trying to achieve is a Treeview of data I have in my database (Works Great). I then want to have the ability to drag and drop nodes and when the event is called I update the ParentID Node.

This is where I am stuck as I currently don't know which event gets called on drag or drop. I've tried various ones in eg: OnSelectedMove etc. but to no avail.

Any help would be greatly appreciated.
Link Posted: 14-Jul-2008 02:21
If you just drag nodes within treeview, then you need to handle NodeMoved event.
This event fires as many times as many node movements occurred since last postback.
This event is fired when treeview loads its postdata (applies client-side changes to its serverside model).
So you shouldn't change state of treeview when handling this event (otherwise, for example there can be a problem if treeview will try to apply client-side change to node that doesn't exist in treeview hierarchy).
Link Posted: 14-Jul-2008 02:32
Thanks for the very prompt reply

I'm still not having much luck with it

                                                    ExpandLevel="2" BorderColor="Silver" BorderWidth="1px" Height="185px" Width="280px"
                            Padding="2px" DragDropAcceptNames="treeviewnode,dragname" DragDropName="treeviewnode"
                            EnableFullRowEvents="True" OnInsertCallbackNodesFromValue="flyTreeView2_InsertCallbackNodesFromValue"
                            OnDropJavascript="flyTreeView2_OnDrop" OnDragOverJavascript="flyTreeView2_OnDragOver"
                            OnDragOutJavascript="flyTreeView2_OnDragOut" RootDragDropAcceptNames="treeviewnode,dragname"
                            FadeEffect="true" OnNodeMoved="flyTreeView2_OnNodeMoved">
                            
                                
                            
                                                            Padding="2px;3px;3px;1px" RowHeight="18px" />
                            
                            
                        



    Protected Sub flyTreeView2_OnNodeMoved(ByVal sender As Object, ByVal e As FlyTreeNodeMovedEventArgs)
        Dim name As New String
    End Sub


Perhaps I've not setup the event method correctly
Link Posted: 14-Jul-2008 02:39
Do you use only ONE treeview? Or several treeview instances? Or drop custom objects onto treeview?
Link Posted: 14-Jul-2008 02:43
It's just 1 treeview, that is populated from a dataset behind the scenes. I know there is all this extra stuff enabled, but I literally copied and pasted from the examples (Drag and Drop)
Link Posted: 14-Jul-2008 03:44
I've been trying some other events and for some reason they are not being kicked off.


                                                                            ExpandLevel="2" BorderColor="Silver" BorderWidth="1px" Height="185px" Width="280px"
                                        Padding="2px" DragDropAcceptNames="treeviewnode,dragname" DragDropName="treeviewnode"
                                        EnableFullRowEvents="True" OnInsertCallbackNodesFromValue="flyTreeView2_InsertCallbackNodesFromValue"
                                        OnDropJavascript="flyTreeView2_OnDrop" OnDragOverJavascript="flyTreeView2_OnDragOver"
                                        OnDragOutJavascript="flyTreeView2_OnDragOut" RootDragDropAcceptNames="treeviewnode,dragname"
                                        FadeEffect="true" OnNodeMoved="flyTreeView2_OnNodeMoved">
                                        
                                            
                                        
                                                                                    Padding="2px;3px;3px;1px" RowHeight="18px" />
                                        
                                        
                                    





                
                                    





    Protected Sub flyTreeView2_OnNodeMoved(ByVal sender As Object, ByVal e As FlyTreeNodeMovedEventArgs) Handles flyTreeView2.NodeMoved
        Dim dasd As String = String.Empty
    End Sub

    Protected Sub flyTreeView2_OnNodeSelected(ByVal sender As Object, ByVal e As FlyTreeNodeEventArgs) Handles flyTreeView2.NodeSelected
        Dim dasd As String = String.Empty
    End Sub



**Note I've just thrown the Handles flyTreeView2. onto the end to see if I could get them kicked off. Could I get an example of a trimmed down drag and drop that handles a select and move event?
Link Posted: 14-Jul-2008 04:06
Everything looks ok, but do you postback page, or do you expect events to be fired without postback?
Link Posted: 14-Jul-2008 04:18
I just thought of that a few minutes ago, didn't realise there was a Move and Select postback, so it's all working now.

Although I have a strange problem where when I try and drag and drop the cursor is behind the control and thus not visible. Is there something that needs to be set to bring this to the front, or perhaps something else?

Finally I was also wondering in my events I do:

Dim hierarchicalData As IHierarchicalEnumerable = NineRays.WebControls.FlyTreeView.ConvertTabularDataToHierarchical(ds, "Table", "Id", "ParentId")
        ' Bind the treeview
        flyTreeView2.DataSource = hierarchicalData
        flyTreeView2.DataBind()

Is :  

"Id" and "ParentId"

Actually stored anywhere in the leaf or are they once off values used to build up the tree? Essentially I have a Parent & Child Id's and I use the Name Column in the Dataset as the text. What would the casting be to get access to "Id" and "ParentId"
Link Posted: 14-Jul-2008 04:24
Does standard Drag and Drop demo work correctly for you? (I mean cursor issue)

FlyTreeView doesn't store ID and ParentID anywhere by default. It just uses these values to determine parent-child relations.
You can save ParentID or ID values in node.Value property. To do this you just need to add a NodeBinding to FlyTreeView.NodeBindings collection and specify ValueField = "Id" in it.
Link Posted: 14-Jul-2008 04:32
The sample works fine, which made me think perhaps I was missing something, like CSS, or setting focus on something. Perhaps it's a small piece of Javascript.

Regarding the bindings:



This is what I thought the binding would be.