Skip to main content
Inspiring
January 8, 2009
Question

Problem controlling Tree properties in the Model...

  • January 8, 2009
  • 1 reply
  • 1230 views
I am trying to control a few properties of a Tree component using properties in the Model.<br /><br />For instance, I have the following properties:<br /><br />public var hierarchyTreeOpenItems:Array /* of Object */ = [];<br />public var hierarchyTreeSelectedItems:Array /* of Object */ = [];<br />public var hierarchyTreeFirstVisibleItem:Object;<br /><br />And I reference them like so:<br /><br /><?xml version="1.0" encoding="utf-8"?><br /><mx:Tree xmlns:mx="http://www.adobe.com/2006/mxml" <br /> width="100%" height="100%" borderStyle="solid" <br /> dataProvider="{__model.hierarchyData}" <br /> firstVisibleItem="{__model.hierarchyTreeFirstVisibleItem}" <br /> openItems="{__model.hierarchyTreeOpenItems}" <br /> selectedItems="{__model.hierarchyTreeSelectedItems}" /><br /><br />I am setting these properties in a Command triggered by the initialize Event of my Application. The openItems works, but I cannot get the Tree to select the specified items, nor can I get it to scroll to the position of the firstVisibleItem.<br /><br />Any thoughts on why this is happening and how I can get it to work?<br /><br />Thanks.
This topic has been closed for replies.

1 reply

Inspiring
January 8, 2009
Here's my solution:

private function creationCompleteHandler():void
{
__model.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, model_propertyChangeHandler);
}

private function model_propertyChangeHandler(
event:PropertyChangeEvent):void
{
switch (event.property)
{
case "hierarchyTreeFirstVisibleItem":
case "hierarchyTreeOpenItems":
case "hierarchyTreeSelectedItems":
{
this.validateNow();

break;
}
}
}