Apache – Can i create multiple itemrenderer for a datagrid column in flex

apache-flex

I actually wanted to create an itemrenderer which will contain below code :

<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="0" height="0" >
 <mx:Label text="{data.xval}" />
 <mx:Spacer width="100%" />
 <mx:Image source="edit.gif" width="16"  toolTip="Edit" />     
</mx:HBox>

Now when i click on the image datgrid column should be editable, for that i am using a textinput as an itemeditor. Now i also want to highlight all those cell for this datagrid column which are having data more than 8 characters. I am able to do this separately using 2 different itemrenderers. but i want to get this all together. Can anyone pls help me to do this? Can we have multiple itemrenderer for any datagrid column?

Please let me know if my question is not clear to you?

Thanking you in advance.

Best Answer

One way to do it is to create a function that returns the name of the style that you want to use for highlighting, and call that function by databinding to the style property of your HBox. For example, if you had one css class named highlight and one named normal, you could use this function:

public function highlight(data:String):String
{
    if(data.length >= 8)
    {
        return "highlight";
    }
    return "normal";
}

And call it like this:

<mx:HBox styleName="{highlight(data.xval)}"> 
    ...
</mx:HBox>
Related Topic