Skip navigation
OULD FELLA
Currently Being Moderated

use condition in flex

Mar 17, 2013 2:45 AM

hi,

I need to use itemrender or something like this to display a value of GridColumn in a different color accordin his value

<s:GridColumn width="120" dataField="email_active" headerText="E-mail active">

                            <s:itemRenderer>

                                <fx:Component>

                                    <s:GridItemRenderer>

                                        <s:Label  backgroundColor="{ data.email_active == 1 ? '#00ff00' : '#FF0000'}" />

                                    </s:GridItemRenderer>

                                </fx:Component>

                            </s:itemRenderer>  

                        </s:GridColumn>

email_active : is a data field from a table of my data base,

the data base is uploaded in datagrid using a php and this code :

<s:AsyncListView id="UserAsyn" list="{getUserResult.lastResult}"/>

 
Replies
  • Currently Being Moderated
    Mar 17, 2013 5:41 AM   in reply to OULD FELLA

    I would suggest using an seperate GridItemRenderer and not one embeded in the GridColumn tag.

     

    First reason, the Label value is only the size of the data length for that item, so setting the background color will only be for the label and not the entire cell.

    Instead of changing the label, make a rectangle graphic item and set it to the width and height of the cell, then set the background color based on the data criteria.

     

    Second reason is to avoid the issue of trying to put a String color value where a uint value is required.

     

    I created and example for something similar, here is the Source View .

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2013 11:26 AM   in reply to OULD FELLA

    Make sure you mark this thread Correct,  Thanks.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points