Professional Documents
Culture Documents
With background
Change style with one property oTree.FolderStyle = "/TreeIcons/Styles/Win2003L"
Background image can be set using ob_tree class in the style sheet.
/* for div where treeview is placed */
div.ob_tree {
background-image: url('../images/wheat.jpg');
For dynamic loading: To change style of the "Loading..." message, modify ob_t7 CSS class.
Example:
/* for message "Loading ..." */
td.ob_t7 {
font:8pt Tahoma;
background-color:#ffffff;
border:1px solid #666666;
color:#666666;
width:80px;
text-align:center;
padding-left:20px;
Below you will find the code for loading a TreeView from an Access database and also (bolded) the
lines added to make the EasyMenu attach to each node loaded:
oTree.FolderIcons = "/TreeIcons/Icons";
oTree.FolderStyle = "/TreeIcons/Styles/Classic";
oTree.AddRootNode("Hello, I am Root node!", null);
Here is the EasyMenu. Please note that there is not AttachTo property added since this is done from
the code above.
Feel free to test on the nodes of the treeview on the right hand side of the page.
Notes:
· Take a look at the following how-to to see how to select the node on right-clicking on it.
· nodeId is used so the node is selected when clicking on the icon. If you do not want the node to be
selcted when clicked on the icon, just remove the line string nodeID; and use this line to add items:
oTree.Add(ParentID, "id" + myReader.GetInt32(0), myReader.GetString(2),
myReader.GetBoolean(3), myReader.GetString(4), null); Take a look at the following how-to to
see how to select the node when clicking on the icon.
When Adding Nodes By Code
We need to create a string that contains all the ids of all nodes to which we want to attach the
EasyMenu, then set the AttachTo property of the EasyMenu to this string:
oTree.FolderIcons = "/TreeIcons/Icons";
oTree.FolderStyle = "/TreeIcons/Styles/Classic";
oTree.AddRootNode("Hello, I am Root node!", null);
Html = "ASPTreeView";
oTree.Add("r1", "a0", Html, true, "Folder.gif\"
onclick=\"ob_t25(document.getElementById('a0'))", null);
attachTo += "a0,";
TreeView.Text = oTree.HTML();
oTree.Width = "150px";
// set the AttachTo property of the EasyMenu to the id list we just
created
EasyMenu1.AttachTo = attachTo;
Here is the EasyMenu. Please note that there is not AttachTo property added since this is done from
the code above.
Feel free to test on the nodes of the treeview on the right hand side of the page.
Notes:
· Take a look at the following how-to to see how to select the node on right-clicking on it.
· When you click on the icon, the node is also selected. If you do not want to that, use "icon.gif"
instead of "icon.gif\" onclick=\"ob_t25(document.getElementById('id'))" for every item you
add. Take a look at the following how-to to see how to select the node when clicking on the icon.