Home - Forums-.NET - FlyTreeView (ASP.NET) - Dynamically Setting Node Properties

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Dynamically Setting Node Properties
Link Posted: 07-Aug-2008 04:27
I have 2 Trees and I would like to dynamically set the properties for certain nodes

Here are both my trees:


                    BorderColor="Silver" BorderWidth="1px" Height="400px" Width="100%" Padding="2px"
                    DragDropAcceptNames="treeviewnode,dragname" DragDropName="treeviewnode" EnableFullRowEvents="True"
                    OnDropJavascript="flyTreeView2_OnDrop" OnDragOverJavascript="flyTreeView2_OnDragOver"
                    RootDragDropAcceptNames="treeviewnode,dragname" FadeEffect="true" PostBackOnDropAccept="True"
                    PostBackOnSelect="true" OnInsertCallbackNodesFromValue="flyTreeView2_InsertCallbackNodesFromValue">
                                            Padding="2px;3px;3px;1px" RowHeight="18px" />
                    
                    
                


                                    BorderColor="Silver" BorderWidth="1px" Height="200px" Width="100%" Padding="2px"
                    DragDropAcceptNames="treeviewnode,dragname" DragDropName="treeviewnode" EnableFullRowEvents="True"
                    OnDropJavascript="flyTreeView2_OnDrop" OnDragOverJavascript="flyTreeView2_OnDragOver"
                    RootDragDropAcceptNames="treeviewnode,dragname" FadeEffect="true" PostBackOnDropAccept="True"
                    PostBackOnSelect="true" OnInsertCallbackNodesFromValue="flyTreeView2_InsertCallbackNodesFromValue">
                                            Padding="2px;3px;3px;1px" RowHeight="18px" />
                    
                    
                



My Code Bind Code:



If ds.Tables(0).Rows.Count > 0 Then

            ' Call FlyTreeView.ConvertTabularDataToHierarchical method to convert into hierarchical datasource
            Dim hierarchicalData As IHierarchicalEnumerable = NineRays.WebControls.FlyTreeView.ConvertTabularDataToHierarchical(ds, "Table", "UID", "Parent")
            bindings.TextField = "Name"
            bindings.ValueField = "UID"
            Me.flyTreeView2.DataBindings.Add(bindings)
            Me.flyTreeView1.DataBindings.Add(bindings)

            ' Bind the treeview
            flyTreeView2.DataSource = hierarchicalData
            flyTreeView2.DataBind()

            flyTreeView1.DataSource = hierarchicalData
            flyTreeView1.DataBind()

        End If



Now this populates the trees perfectly from a Dataset. I was browsing the forums and found this :


                
                    
                        
                            
                            
                            
                        
                    
                
                
                    
                        
                            
                                
                                
                            
                            
                                
                                
                            
                        
                    
                


What I am uncertain about is how I would set the properties for the nodes in the code. What I would like to do is

flyTreeView1 : Only allow nodes to be dragged onto the root, which are of type products.

flyTreeView2 : Only allow products from flyTreeView1  to be dragged onto Customers. Do not allow any nodes to be dragged or dropped within FlyTreeView2 unless it is a product being moved onto another customer.

I am just not sure how I go about setting this via code. I guess I need to take my treeview objects and iterate through all the nodes.

flyTreeView1 is arranged into:

-Route
--Run
---Customer
----Products

So I would like to set values for Products and if possible blanket apply values to everything else.

flyTreeView2 is arranged into:

-Products

It should just be a straight list without the ability to add any children.
Link Posted: 10-Aug-2008 23:23
FlyTreeNode (as well as FlyNodeType) has DragDropName and DragDropAcceptNames (comma separated).
You can define nodetypes for different kinds of nodes, or set DragDropName and DragDropAcceptNames properties for each node.

If you use data binding, then you'll probably need to handle NodeDataBound event. In handler, you can set up data bound node properties depending on some conditions.
Link Posted: 11-Aug-2008 02:42
I worked out a system by placing a type in my dataset, it makes the binding far faster as I can just set the values for those types that I need.