Flex's tree expands to shrink, Ji expands to select a single node

Source: Internet
Author: User

Expand All
Private Function ExpandAll (): void
{

Treemenu.dataprovider is a data source that is bound by ID Treemenu is a xmllist
For each (Var item:xml in Treemenu.dataprovider)
Treemenu.expandchildrenof (item,true);
}
All collection
Private Function CollapseAll (): void {
For each (Var item:xml in Treemenu.dataprovider)
Treemenu.expandchildrenof (Item,false);
}

Expand MO Node parameter item is an XML object

Treemenu.expandchildrenof (item,true);

Check item2 node is an XML object
Treemenu.selecteditem = item2;

3. Move the scroll bar to the corresponding node after locating the node in the tree component: A method for Tree.scrolltoindex (index)

Select node

Tree.selecteditem = Fieldnode;
Set scroll bar to scroll to the appropriate position
var index:int = tree.selectedindex;//The position of the current node

Tree.scrolltoindex (Index)//scroll bar to the position of the current node

Method 2: Set the scroll bar to scroll to the appropriate location:

Tree.verticalscrollposition = Position

Api:

Verticalscrollposition Property
Verticalscrollposition:number []

The offset from the top edge to the content. This can be a pixel offset in some subclasses, or some other metric, such as the number of rows in a list or the number of tiles in TileList.

The default value is 0.

This property can be used as the source for data binding.

Tree Expand All you can also use the following method:

Tree.openitems = Item//item data to expand

Tree.openitems = [];//all collection

In the API:

Openitems Property
Openitems:object []

A project that has been opened or has been set to open.

The default value is null.

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.