Index of the selected node:
Tree. selectednodeindex
Index of the clicked node:
Tree. clickednodeindex
Get a node:
Tree. gettreenode (nodeindex)
Add a subnode under the root node:
VaR tree = Document. All ['treeview1'];
VaR node = tree. createtreenode ();
Tree. Add (node );
Node. setattribute ("text", "aaaa ");
Add a subnode to the current node:
VaR tree = Document. All ['treeview1'];
VaR node = tree. createtreenode ();
VaR parentnode = tree. gettreenode (tree. clickednodeindex );
Parentnode. Add (node );
Node. setattribute ("text", "aaaa ");
- Add sub-nodes using XML files:
Node. setattribute ("navigateurl", "XXX ");
Node. databind ();
- Automatically expand after adding a subnode dynamically:
Node. setattribute ('expanded', 'true'); // you need to modify a location in HTC provided by Ms. Otherwise, an exception occurs.
- Get node attributes:
Node. getattribute ("XXX ")
- Set node attributes:
Node. setattribute ('xxx', 'xxxx ');
- List of common attributes:
Attribute |
Value |
Description |
Checkbox |
True False |
Select box? |
Checked |
True False |
Whether or not the selection box is selected |
Expanded |
True False |
Expand? |
Imageurl |
|
Icon on the left |
Selectedimageurl |
|
Icon on the left when the node is selected |
Expandedimageurl |
|
Icon on the left after the node is expanded |
Target |
|
Target framework |
Navigateurl |
|
Target URL |
Type |
|
Node Type |
Childtype |
|
Subnode type |
Text |
|
Text displayed on the node |
Innertext |
|
|
Innerhtml |
|
|
Defaultstyle |
|
Default Style |
Hoverstyle |
|
The style of moving the mouse over the node |
Selectedstyle |
|
Style when a node is selected |
Treenodesrc |
|
|
- Get parent node:
Node. getparent ()
- Obtain subnodes:
Node. getchildren ()
- Determine whether a node has a subnode
Node. getchildren (). length> 0
- Response to the onselectedindexchange event:
VaR tree = Document. All ["tvmain"];
Tree. attachevent ("onselectedindexchange", selectedindexchange );
Reprinted from: http://www.cnblogs.com/jacker1979/articles/1077036.html