Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tool to create Hierarchical Data
Message
 
To
21/06/2006 18:54:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01130436
Message ID:
01130712
Views:
22
Hi Cetin.
Thanks very much for your very lengthy and informative reply.
In order to get a sample up and running, I thnk I'll use the VFP sample APP.

Where do I find the solyions app with the tree view control ?

Regards,
Gerard



>No it's not that simple.
>What I mean is for a hierarchical data you basically need 3 columns (other columns might exists as user data columns). ie:
>
>NodeID: uniqueID of a node
>ParentNodeID: nodeID of parent node
>NodeText: Text to be displayed
>
>If you think of 2 tables like customer and orders:
>
>NodeID   ParentID NodeText
>------   -------- --------
>ALFKI             Alfreds futterskie
>ord_001  ALFKI    Some text from orders
>
>nodeID is primarykey and parentid is foreignkey.
>
>Nodes are TreeNode collection items. You can add another TreeNode to a TreeNode making it chidren of that node etc. When adding a node ifyou use TreeNode(string,string) constructor then you're adding a node with a key (nodeID) and NodeText. So you can load/save data from/to many sources. Those sources could be objects which internally already have "children". ie:(from help walkthroughs "Walkthrough: Connecting to Data in Objects")
>
>namespace ObjectBindingWalkthrough
>{
>//...
>    public class Customer
>    {
>        public Customer()
>        {
>        }
>//...
>        public Customer(string customerID, string companyName,
>           string contactName, string contactTitle,
>           string address, string city, string region,
>           string postalCode, string country,
>           string phone, string fax)
>        {
>            customerIDValue = customerID;
>        }
>//...
>        private System.ComponentModel.BindingList<Order> ordersCollection =
>            new System.ComponentModel.BindingList<Order>();
>
>        public System.ComponentModel.BindingList<Order> Orders
>        {
>            get { return ordersCollection; }
>            set { ordersCollection = value; }
>        }
>//...
>    }
>}
>
And order objects might in turn contain "order detail" objects. Adding this type of data to a Treeview is trivial. Suppose you have a slightly modified version which also adds a private member to each object - taking into account objects might not have uniqueIds themselves like an integer as with autoinc value or identity:
>
>private Guid _uniqueID=Guid.NewGuid();
>public string OID { get {return this._uniqueID.ToString("N");}}
>
>Create a new TreeNode:
>
>{
>//...
>TreeNode customerNode = new TreeNode();
>customerNode.Name = currentCustomer.OID;
>customerNode.Text = currentCustomer.Company;
>foreach(Order ord in currentCustomer.Orders)
>{
> TreeNode orderNode = new TreeNode();
> orderNode.Name = ord.OID;
> orderNode.Text = String.Format("Order# {0} ordered on {1}",
>   ord.OrderId,   ord.OrderDate);
> customerNode.Nodes.Add(orderNode);
>}
>myTreeView.Nodes.Add(customerNode);
>//..
>}
>
Treeview class in .Net compared to activex version available for VFP is really content rich. Besides simple sample above TreeNode supports directly putting object to its Tag property and (if you don't have other means of preserving its data - note that above walkthrough sample is data < - > object sample) it also implemets ISerializable interface,ICloneable and MarshalByRefObject (meaning that you could serialize to say XML or memory stream and pass from machine to machine via remoting etc).
>Unfortunately I don't have an out of the box sample here. However VFP solution.app has one adding/removing nodes with allowing editing of nodes (LabelEdit) and saving/loading to a dbf. Also in UT magazine first issue I have a short article about it (populate on demand approach in that article is obsolete with webforms version of TV because it has it as a property - I don't understand why missing from winforms version). You can even do it with the inferior activex one IOW so you should be much more comfortable now.
>Cetin
>
>>Hi Cetin. Thanks for your reply.
>>
>>Does this mean that, with no programming, you can use a Tree View Control to add new nodes, add sub nodes to existing nodes etc.
>>
>>Pardon my unfamiliarity with dot not, but in VFP terms , is is just a matter of setting a Contol Source to an XML file and the XML file is automaticlly updated ?
>>
>>Regards,
>>Gerard
>>
>>
>>
>>
>>>>Hi.
>>>>I an trying to set up Tree Style data and then be able to view the data.
>>>>A tree view should allow me to view the data , but does anybody know of any Tool to allow me to create thet Data in the first place.
>>>>The data will consist of just one field but in a tree type structure where you can gave children.. grandchildren, Greatgrandchildren etc.
>>>>
>>>>Dept1
>>>> Dept1.1
>>>> Dept1.2
>>>>Dept2
>>>> Dept2.1
>>>> Dept2.1.1
>>>> Dept2.2.2
>>>>Dept3
>>>>Dept4
>>>> Dept4.1
>>>> Dept4.2
>>>> Dept4.3
>>>> Dept4.3.1
>>>> Dept4.3.2
>>>>etc.
>>>>It does'nt matter really what type of a file this is held in as long as it can be viewd in a Tree View.
>>>>
>>>>I know I could write an App to do this but theres probably something already there ??
>>>>
>>>>Regards,
>>>>Gerard
>>>
>>>Gerard,
>>>You can use treeview for data entry too. Check TreeView.LabelEdit property for a sample.
>>>Any table with 3 columns or XML would do for storing the data.
>>>Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform