0
votes

I have a tree component sitting in a divided box. I want to display '...' on the node labels if the divided box is resized. I have a custom itemrenderer and have been looking at the labelFunction property as well as trying various approaches in the custom itemrenderer. Not having any joy. Any pointers would be appreciated.

heres some sample code fo how I set it up...

I define a tree...

<mx:Tree 
id="tree"
dataProvider="myData" 
labelFunction="treeNodeLabel"
width="100%" height="100%"
click="handleClick(event)"
mouseMove="handleMouseMove(event)"
itemRollOver="handleItemOver(event)"
itemRollOut="handleItemOut(event)"
doubleClickEnabled="true"
doubleClick="handleDoubleClick(event)"
iconFunction="customIcon"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
dragOver="onDragOver(event)"
dragStart="onDragStart(event)"
dataDescriptor="{new DiagramTreeDataDescriptor()}"
itemRenderer="myCustomeRenderer"
borderStyle="none"
>

The Custom Renderer is an Actionscript class that extends TreeItemRenderer...

public class myCustomRenderer extends TreeItemRenderer {

public function myCustomRenderer() {
  super();
}

/**
 * Create child objects of the component.
 */
override protected function createChildren():void {
  super.createChildren();
  createIcon(); 
  addListeners();
  addChild(Icon1); 
  addChild(Icon2); 
} 


private function createIcon() : void {
   ...
}

private function addListeners() : void {
   ...
}

private function Icon1Click(event: MouseEvent):void {
   ...              
}

private function Icon2Click(event: MouseEvent): void {
   ...
}  

private function onLabelMouseOver(event : MouseEvent):void {
   ...
}

private function onLabelMouseOut(event : MouseEvent):void {
   ...
}

private function getDescription(node : XML):String  {  
   ...            
}

override protected function updateDisplayList(...) {
   ...
} 

override public function set listData(value:BaseListData):void  { 
   ...
} 

}

1
Are you using a s:Label inside your renderer?Exort
Hi, I'm fairly new to flex so apologies if i'm a little vague! The answer is no (I think!). While I have a cutom renderer, it is used to control other things, such as clicking on an icon that is also displayed for each node. I think i am using whatever display method is the default. For example I refer to super.label in my custom renderer and it "apprears" to be a TextField (which doesn't support truncate). Sorry again if this is vaguefatlog
Maybe you could post some code to make things clearerExort
I added some sample code to the postfatlog

1 Answers

0
votes

You can set

labelDisplay.maxDisplayedLines = 1

Also, to be able to truncate, the labelDisplay must have a specified width. I don't know what's the default behavior inside a renderer. You can try to first set a width on the renderer itself (absolute or in percentage). If it does not work, set it on the labelDisplay.