Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:09:16+00:00 2026-06-18T09:09:16+00:00

I’m trying to alternate between two background colors for each cell in a datagrid.

  • 0

I’m trying to alternate between two background colors for each cell in a datagrid. It changes its state upon double clicking in a particular cell.

What I want is that the user be able to select individuals cell in a Datagrid so #FFFFFF color is for unselected cells and #CDCDCD for selected ones.

I have the following code for an ItenRenderer:

    <?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:s="library://ns.adobe.com/flex/spark" 
                    xmlns:mx="library://ns.adobe.com/flex/mx" 
                    clipAndEnableScrolling="true">

    <fx:Script>
        <![CDATA[
            override public function prepare(hasBeenRecycled:Boolean):void {
                //lblData.text = data[column.dataField]
            }
        ]]>
    </fx:Script>

    <s:states>
        <s:State name="normal"/>
        <s:State name="selected"/>
    </s:states>

    <s:Label id="lblData" top="9" left="7" text="10" width="100%" height="100%" textAlign="center"/>
    <s:Rect width="100%" height="100%">
        <s:fill>
            <s:SolidColor color.selected="#CDCDCD" color.normal="#FFFFFF"/>
        </s:fill>
    </s:Rect>

</s:GridItemRenderer>

The question is that label is never shown due to the rect component hide it. how can i accomplish this?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:09:17+00:00Added an answer on June 18, 2026 at 9:09 am

    Try this:

    enter image description here

    //Application

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
    
            [Bindable]private var initDG:ArrayCollection = new ArrayCollection([
                {Artist:'01', Album:'Album 01', Year:'2008'},
                {Artist:'02', Album:'Album 02', Year:'2009'},
                {Artist:'03', Album:'Album 03', Year:'2007'},
                {Artist:'04', Album:'Album 04', Year:'2003'},
            ]);
        ]]>
    </fx:Script>
    
    <s:VGroup>
        <s:DataGrid id="myGrid" width="360" dataProvider="{initDG}">   
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn dataField="Artist" headerText="Artist" itemRenderer="com.dgcoloredcells.CellRenderer"/>
                    <s:GridColumn dataField="Album" headerText="Album" itemRenderer="com.dgcoloredcells.CellRenderer"/>
                    <s:GridColumn dataField="Year" headerText="Year" itemRenderer="com.dgcoloredcells.CellRenderer"/>
                </s:ArrayList>
            </s:columns>       
        </s:DataGrid> 
    </s:VGroup>
    </s:Application>
    

    //Renderer

    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:s="library://ns.adobe.com/flex/spark" 
                    xmlns:mx="library://ns.adobe.com/flex/mx" 
                    implements="mx.controls.listClasses.IDropInListItemRenderer">
    <fx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridListData;
            import mx.controls.listClasses.BaseListData;
    
            private var _listData:BaseListData;
    
            [Bindable]private var isSelected:Boolean = false;
    
            override public function set data( value:Object ) : void 
            {
                super.data = value;
                lblData.text = data[column.dataField];
            }
    
            [Bindable]public function get listData() : BaseListData
            {
                return _listData;
            }
            public function set listData( value:BaseListData ) : void
            {
                _listData = value;
            }
    
            private function onClick(evt:Event):void
            {
                isSelected = !isSelected;
            }
        ]]>
    </fx:Script>
    
    <s:Rect width="100%" height="100%">
        <s:fill>
            <s:SolidColor color="{isSelected ? 0xCDCDCD : 0xFFFFFF}"/>
        </s:fill>
    </s:Rect>
    
    <s:Label id="lblData" top="9" left="7" width="100%" height="100%" textAlign="center" doubleClickEnabled="true" doubleClick="onClick(event)"/>
    
    </s:GridItemRenderer>
    

    //EDIT
    Here you can see my screenshot for data[column.dataField] problem:

    enter image description here

    Here is the coresponding value object

    enter image description here

    So data[column.dataField] = data[“Artist”] = “01”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.