Microsfot. Web. UI. webcontrols. Treeview JavaScript Control Method

Source: Internet
Author: User
  1. Index of the selected node:
    Tree. selectednodeindex

  2. Index of the clicked node:
    Tree. clickednodeindex

  3. Get a node:
    Tree. gettreenode (nodeindex)

  4. Add a subnode under the root node:
    VaR tree = Document. All ['treeview1'];
    VaR node = tree. createtreenode ();
    Tree. Add (node );
    Node. setattribute ("text", "aaaa ");

  5. 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 ");

  6. Add sub-nodes using XML files:
    Node. setattribute ("navigateurl", "XXX ");
    Node. databind ();
  7. 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.
  8. Get node attributes:
    Node. getattribute ("XXX ")
  9. Set node attributes:
    Node. setattribute ('xxx', 'xxxx ');
  10. 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    

  11. Get parent node:
    Node. getparent ()
  12. Obtain subnodes:
    Node. getchildren ()
  13. Determine whether a node has a subnode
    Node. getchildren (). length> 0
  14. Response to the onselectedindexchange event:
    VaR tree = Document. All ["tvmain"];
    Tree. attachevent ("onselectedindexchange", selectedindexchange );

Reprinted from: http://www.cnblogs.com/jacker1979/articles/1077036.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.