How do i change the cell color of each cell in datagrid dynamically

I have a  datagrid filled in with data..My job is to change the cell color of a particular cell in the datagrid when the user clicks that cell..Please help me asap..I have to change the color of each cell dynamically..

Pls find the solution of ur problem.Let me know if you have any issue.
MainApplicaion.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.ListEvent;
            [Bindable]
              private var listDataArrayCollection:ArrayCollection=
              new ArrayCollection([
                {seq:'1',color:'0xFF0000', names:'John'},
                {seq:'2',color:'0x00FF00', names:'Alex'},
                {seq:'3',color:'0x0000FF', names:'Peter'},
                {seq:'4',color:'0xFF0000', names:'Sam'},
                {seq:'5',color:'0x00FF00', names:'Alis'},
                {seq:'6',color:'0x0000FF', names:'Robin'},
                {seq:'7',color:'0xFF0000', names:'Mark'},
                {seq:'8',color:'0x00FF00', names:'Steave'},
                {seq:'9',color:'0x0000FF', names:'Fill'},
                {seq:'10',color:'0xFF0000', names:'Abraham'},
                {seq:'11',color:'0x00FF00', names:'Hennery'},
                {seq:'12',color:'0x0000FF', names:'Luis'},
                {seq:'13',color:'0xFF0000', names:'Herry'},
                {seq:'14',color:'0x00FF00', names:'Markus'},
                {seq:'15',color:'0x0000FF', names:'Flip'},
                {seq:'16',color:'0xFF0000', names:'John_1'},
                {seq:'17',color:'0x00FF00', names:'Alex_1'},
                {seq:'18',color:'0x0000FF', names:'Peter_1'},
                {seq:'19',color:'0xFF0000', names:'Sam_1'},
                {seq:'20',color:'0x00FF00', names:'Alis_1'},
                {seq:'21',color:'0x0000FF', names:'Robin_1'},
                {seq:'22',color:'0xFF0000', names:'Mark_1'},
                {seq:'23',color:'0x00FF00', names:'Steave_1'},
                {seq:'24',color:'0x0000FF', names:'Fill_1'},
                {seq:'25',color:'0xFF0000', names:'Abraham_1'},
                {seq:'26',color:'0x00FF00', names:'Hennery_1'},
                {seq:'27',color:'0x0000FF', names:'Luis_1'},
                {seq:'28',color:'0xFF0000', names:'Herry_1'},
                {seq:'29',color:'0x00FF00', names:'Markus_1'},
                {seq:'30',color:'0x0000FF', names:'Flip_2'}
            private function onItemClick(event : ListEvent):void
                var dataObj : Object = event.itemRenderer.data;
                dataObj.color = "0xFF00FF";
                event.itemRenderer.data = dataObj;
        ]]>
    </mx:Script>
    <mx:VBox width="300" height="100%"
        horizontalAlign="center"
        verticalAlign="middle">
        <mx:DataGrid id="listComponent" width="50%"
                 height="100%"
                 borderStyle="none"
                 dataProvider="{listDataArrayCollection}"
                 itemClick="onItemClick(event)">
                 <mx:columns>
                 <mx:DataGridColumn width="100" dataField="{data.seq}" headerText="Seq" itemRenderer="SeqItemRenderer" />
                 <mx:DataGridColumn width="100" dataField="{data.names}" headerText="Name" itemRenderer="NameItemRenderer"/>
                 </mx:columns>
                 </mx:DataGrid>
    </mx:VBox>
</mx:Application
NameItemRenderer.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
    width="100" height="30" horizontalGap="5" horizontalScrollPolicy="off">
<mx:Script>
    <![CDATA[
        override public function set data(value:Object):void
             super.data = value;
    ]]>
</mx:Script>
        <mx:TextInput width="75" height="30"
             text="{data.names}"
             editable="false" backgroundColor="{data.color}"/>
    </mx:HBox>
SeqItemRenderer.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
    width="100" height="30" horizontalGap="5" horizontalScrollPolicy="off">
<mx:Script>
    <![CDATA[
        override public function set data(value:Object):void
             super.data = value;
    ]]>
</mx:Script>
        <mx:TextInput width="75" height="30"
             text="{data.seq}"
             editable="false" backgroundColor="{data.color}"/>
    </mx:HBox>
with Regards,
Shardul Singh Bartwal

Similar Messages

  • Change the background color of a cell in JTable

    Hi all,
    How can I change the background color of individual cell in JTable. I need to construct my own TableCellRenderer or not? I'm now using the DefaultTableCellRenderer now.
    Thx

    You could create your own renderer or you could try something like:
    table = new JTable(model)
         public TableCellRenderer getCellRenderer(int row, int column)
              DefaultTableCellRenderer tcr =
               (DefaultTableCellRenderer)super.getCellRenderer(row, column);
              if (row == 1 && column == 1)
                   tcr.setBackground(Color.green);
              else
                   tcr.setBackground(Color.red);
              return tcr;
    };

  • How to change the background color of a cell in datagrid using flex3

    i want to change the background color of a cell.....how can i achieve this.....and also i want to know how a spacing cane be done between cells in a datagrid...plzzz help me???

    The only way I can see to do this is to use an item renderer for your cells.  This is really scruffy and would need tyding up, and maybe with a little more time could do better or someone else may have an idea but none the less this works.
    Define a custom component as below;
    This has logic to see what the value of the data is proveided by the dataprovider for the row, and if it matches the conditions in this case is equal to 5 sets the background color.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="88" height="26" dataChange="doColor()" borderColor="#000000" borderStyle="solid"
        backgroundAlpha="1">
        <mx:Script>
            <![CDATA[
                private function doColor():void {
                    if (data.value == 5) {
                        setStyle('backgroundColor', 0xcccccc);
                    } else {
                        setStyle('backgroundColor', 0xffffff);
            ]]>
        </mx:Script>
    </mx:Canvas>
    Now just apply the item renderer in the datagrid and that will do it.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  xmlns:ns1="*">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var ac:ArrayCollection = new ArrayCollection([
                    {value : 1},
                    {value : 2},
                    {value : 3},
                    {value : 4},
                    {value : 5},
                    {value : 6},
                    {value : 7},
                    {value : 8},
                    {value : 9},
                    {value : 10}
          ]]>
        </mx:Script>
        <mx:DataGrid x="40" y="36" width="408" height="193" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="value" itemRenderer="MyComp"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    I hope this helps
    Andrew

  • How to change the Background color of a cell in JTable

    hi!
    Actually i want to change the background color of few cells in JTable
    is there any method to make this change in JTable ?
    and also is it possible to have 5 rows with single column and 5 rows with 3 columns in a single JTable

    i want to change the background color of few cells in JTableDepending on your requirements for the coloring of cells it may be easier to override the prepareRenderer() method of JTable:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474

  • How do I change the background color of a row in a table indicator?

    Hello,
      How do I change the background color of a row in a table indicator? I know how to change the background color in a active cell, but that is not what I want. My first intent is to make the background color of the first row a unique color, such as green, just to highlight the top row of the table.
    Regards,
    Kaspar
    Regards,
    Kaspar

    I have done this before by using a for loop to change the active cell of a row in order to give the appearance that the whole row is turning the color at once.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How do I change the background color of a poster in pages?

    How do I change the background color using pages for ipad?  I am working with a poster template.

    I have done this before by using a for loop to change the active cell of a row in order to give the appearance that the whole row is turning the color at once.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How do I change the background of a single cell or a row in a table?

    How do I change the background of a single cell or a row in a
    table? I doesn't seem to be letting me do that.

    Are you using the latest DW? If so, then it isn't letting you
    because
    bgcolor is deprecated and shouldn't be used.
    The correct way is to use css to define the background of a
    cell
    CSS:
    .blackcell {background-color: black;}
    HTML:
    <td class="blackcell">whatever in the cell</td>
    Nadia
    Adobe® Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    ~ Template Customization ~
    http://www.csstemplates.com.au
    Spry Widget Examples
    http://www.dreamweaverresources.com/spry-widgets/
    "dm25" <[email protected]> wrote in message
    news:f4jr5h$luu$[email protected]..
    > for some reason that doesn't always work. When I click
    inside a cell, it
    > doesn't give me an option to change the background
    color.

  • In Pages 5.0 How do I change the highlight color?

    In Pages 5.0 How do I change the highlight color?

    Oh!  I understand now.  See screenshot below.  It's called "Character Fill Color":

  • How can I change the background color in the inbox?

    The background color in my inbox (well, all mailboxes) is white. A yellow background would make the existing black text a lot easier to read. How can I change the background color in the inbox?

    Themes work in Thunderbird - duggabe was not refering to Firefox.
    Another useful addon is theme and font changer:
    * https://addons.mozilla.org/fr/thunderbird/addon/theme-font-size-changer/
    However, Thunderbird allows you to modify all sorts of things.
    Make hidden files and folders visible:
    * http://kb.mozillazine.org/Show_hidden_files_and_folders
    Help > Troubleshooting Information
    Click on 'show Folder' button
    a window opens shwoing profile folder name
    Close Thunderbird now - this is important
    In the profile name folder, Create a new folder called '''chrome''' - note the spelling
    It should be in the same place as the 'Mail' folder.
    see first image below.
    Open Notepad
    Can be located : Start > Programs > accessories
    Copy everything shown between the lines below.
    Paste into Notepad.
    Save as '''userChrome.css''' - note the spelling (edit updated - this was a typo error)
    This should be saved in the '''chrome''' folder.
    see second image below.
    Restart Thunderbird.
    I have chosen a yellow for you
    <pre>
    #f6f58c = a yellow....it is a hex code for a colour.
    </pre>
    You can change it if required. Remember when updating anything in the profile folders, you must close Thunderbird first.
    More info on colours.
    * http://www.yourhtmlsource.com/stylesheets/namedcolours.html
    <pre>
    * Do not remove the @namespace line -- it's required for correct functioning
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
    /*Background colour for message list*/
    #threadTree > treechildren::-moz-tree-row {
    background-color: #f6f58c !important;
    </pre>
    -------------------------------------------

  • How do I change the line color in a chart in Numbers on my iPad?

    How do I change the line color in a chart in Numbers on my iPad?

    Whenever I try to shift+direct select it thinks I want to move the line, so as I shift + direct select and drag my mouse across the line (to highlight it all) it moves a chunk of the line and turns it into a near perpendicular line.
    I found the appearance window, it just says "Path" (the color I want it to be that it's not)
    "Stroke" 4pt
    "Fill" (the color I want it to be that it's not)
    "Opacity": Default
    And some other buttons. I think I'll try the help line tomorrow, I know I saw a customer service number somewhere and I'm only here because the chat was unavailable. This is only one of my 3 problems with my assignment so I'll search here for answers to the other two. Learning new things is rarely fun.

  • How do i change the text color in ichat?

    How do i change the text color in ichat?

    Hi,
    In One Chat by word or letter go to the Format Menu as you type (Highlight and change like you would in any other App)
    On a more permanent basis the Font, it's colour and the IM background colour are set in iChat Menu > Preferences > Messages
    10:12 PM      Wednesday; November 23, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How do i change the backgound color for the "file edit view history bookmark tools help" bar in Firefox 29.0

    how do i change the backgound color for the "file edit view history bookmark tools help" bar in Firefox 29.0

    You can add a solid color theme to change the color of the top of the browser window, which includes the Menu Bar.
    https://addons.mozilla.org/en-US/firefox/themes/solid

  • How do I change the default color in pages.

    How do I change the default color in pages.  Everytime I try to copy and paste a passage, I am unable to do so because it seems that the ink is always white on white.  Sometimes I am lucky and can change it using the color box in the format bar, but it's a rarity when I'm able to do it.

    What version of Pages & what version of OS X are you using?
    A problem with an early Software Update for Snow Leopard caused a lot of problems. The problem is not whether or not your system is the current version but how it got there. You must use the combo updater, not the one from Software Update unless it specifically states it is the combo. Software Update will only offer the combo if your system is two or more versions behind.
    If you're not running the latest versions of the iWork apps & Software Update says your software is up to date, make sure the applications are where the installer initially put them. The updaters are very picky. If the location is not where the updater is programmed to look or if the folder doesn't have the name the updater looks for, it will not work. The applications cannot be renamed or moved. If you installed from the downloaded trial or the retail box, they must be in the iWork '09 (or '08 if that's what you're using) folder in Applications. That iWork folder must be named iWork '09. If it doesn't have the '09 Software Update won't find them & the updaters won't work.

  • How do i change the highlight color on iphone5?

    How do i change the highlight color on iphone5?
    It is a gray color but I want it to be blue again.

    You can find it under the Pages menu > Provide Pages Feedback. That takes you to the same page as this link.

  • How do I change the text color from blue in Safari on Macbook Pro?

    I have trouble seeing the light blue text color -- many article use this.  How can I change the text color?

    Is this a particular website where you see the light blue color?
    If so, please post a link to that site in your Reply.
    Exactly which light blue color are you referrting to ??

  • How do I change the font color for numbering in a matching question slide?

    I have a grey image on a question slide, but the numbering for the answers in a matching question is defaulting to grey so learners can't see to match up.  How can I change the font color of these choices?  Thanks.

    You probably edited the master slide without changing the theme colors? Check the Object Style for Answers in the Object Style Manager. The numbering takes the same color as the answer text.
    All depends on the Theme colors palette that you are using. Normally Question answers use the darkest tint of the fourth color. I started blogging about color management, but description of the use of Theme colors will be published later.
    Colorful 2015 with Adobe Captivate - Captivate blog

Maybe you are looking for

  • What's this sandboxd mdworker deny mach-lookup thing about?

    My newer iMac keeps locking up over many months. It seems to be getting more frequent. All updated are made and I'm running OS10.8.2. Each time I've looked at the console log one of the last entries has been related to mdworker and sandboxd. This is

  • Java 2 SDK v 1.3

    Does anyone know where exactly I can download Java 2 SDK v 1.3? I downloaded the 1.4 but I seem to be having problems with compatibility. (The school computers use 1.3 and some of their stuff did not work on my 1.4) (Oh, we are using Bluej to program

  • Item Categories in Popup

    Hi, We have a requirement where we need the Popup for Item categories in Opportunity which is like after selecting the Opportunity type we should get another Popup of Item categories.  Is this possible with standard confirguration.  We are using the

  • Call a dll for Labview: Function not found in library

    Hello, I am trying to call a very simple .dll form Labview. I compiled the .dll for x64 using Visual Studio 2010, because I am using Labview(64-bit). I did everything exactly the way I read it in several Tutorials. But the "Call Library Function Node

  • [SOLVED] kde4.4: kontact does only display startpage

    Hey there, since upgrading to kde4.4 i am having issues running kontact. The problem is it does not know about its plugins like kmail, akregator etc. even though they are installed. When running: kontact --list kontact(28561)/kdecore (KSycoca) KSycoc