[flexcoders] Re: Conditional formatting of tree node labels

2007-05-26 Thread barry.beattie
Ivo, did you find a solution?

the tree controls' "labelFunction" (instead of "labelField") could be
an easy way out to conditionally modify the label's condition0

just a quick suggestion

best'o'luck
barry.b





private function treeLabel( item:Object ) : String
{
 var node:XML = XML(item);
 var labelText:String;
 // choose what to use for label
 // TODO: replace hard-coded node name with [if not hasChildren]
 if( node.localName() == "question")
 {
labelText = String([EMAIL PROTECTED]);
 }
 else 
 {
labelText = String([EMAIL PROTECTED]);
 }
 if (labelText.length > 30) // too long
 {
labelText = labelText.substr(0,30) + "...";
 } 
 return labelText;
}   




Re: [flexcoders] Re: Conditional formatting of tree node labels

2007-06-04 Thread ivo
Thanks for the response Barry. I was away & just now
catching up on email.

Turns out I did not have to do:

var treeListData:TreeListData =
TreeListData(super.listData);
if(treeListData.isDirty){
this.label.setStyle('fontStyle', 'italic');
}

but just:

var treeListData:TreeListData =
TreeListData(super.listData);
if(treeListData.isDirty){
setStyle('fontStyle', 'italic');
}

I had one of those doh moments when I noticed it.

Regards,

Ivo


--- "barry.beattie" <[EMAIL PROTECTED]> wrote:

> Ivo, did you find a solution?
> 
> the tree controls' "labelFunction" (instead of
> "labelField") could be
> an easy way out to conditionally modify the label's
> condition0
> 
> just a quick suggestion
> 
> best'o'luck
> barry.b
> 
> 
>  dataProvider="{questionaire.section}" 
> labelFunction="treeLabel" 
> change="onTreeNodeSelected(event)"
>   />  
> 
> 
> private function treeLabel( item:Object ) : String
> {
>  var node:XML = XML(item);
>  var labelText:String;
>  // choose what to use for label
>  // TODO: replace hard-coded node name with [if
> not hasChildren]
>  if( node.localName() == "question")
>  {
>   labelText = String([EMAIL PROTECTED]);
>  }
>  else 
>  {
> labelText = String([EMAIL PROTECTED]);
>  }
>  if (labelText.length > 30) // too long
>  {
>   labelText = labelText.substr(0,30) + "...";
>  } 
>  return labelText;
> } 
> 
> 
>