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 5952377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:40:23+00:00 2026-05-22T17:40:23+00:00

The checkboxes are updated correctly when I select one or more datagrid rows but

  • 0

The checkboxes are updated correctly when I select one or more datagrid rows but when I select a checkbox for the first time the checkbox does not refresh until the pointer moves out of the datagrid row. How can I fix this?

<?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">
    <s:DataGrid id="dg" x="344" y="48" selectionMode="multipleRows" requestedRowCount="4">
        <s:columns>
            <s:ArrayList>
                <s:GridColumn>
                    <s:itemRenderer>
                        <fx:Component>
                            <s:GridItemRenderer>
                                <fx:Script>
                                    <![CDATA[
                                        import mx.controls.Alert;
                                        import spark.components.DataGrid;

                                        override public function prepare(hasBeenRecycled:Boolean):void
                                        {
                                            cb.selected = grid.selectionContainsIndex(rowIndex);
                                        }
                                    ]]>
                                </fx:Script>
                                <s:CheckBox id="cb" label="" horizontalCenter="0"/>
                            </s:GridItemRenderer>
                        </fx:Component>
                    </s:itemRenderer>
                </s:GridColumn>
                <s:GridColumn dataField="dataField1" headerText="Column 1"></s:GridColumn>
                <s:GridColumn dataField="dataField2" headerText="Column 2"></s:GridColumn>
                <s:GridColumn dataField="dataField3" headerText="Column 3"></s:GridColumn>
            </s:ArrayList>
        </s:columns>
        <s:typicalItem>
            <fx:Object dataField1="Sample Data" dataField2="Sample Data" dataField3="Sample Data"></fx:Object>
        </s:typicalItem>
        <s:ArrayList>
            <fx:Object dataField1="data1" dataField2="data1" dataField3="data1"></fx:Object>
            <fx:Object dataField1="data2" dataField2="data2" dataField3="data2"></fx:Object>
            <fx:Object dataField1="data3" dataField2="data3" dataField3="data3"></fx:Object>
            <fx:Object dataField1="data4" dataField2="data4" dataField3="data4"></fx:Object>
        </s:ArrayList>
    </s:DataGrid>
</s:Application>
  • 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-05-22T17:40:24+00:00Added an answer on May 22, 2026 at 5:40 pm

    You can just fake the CheckBox by drawing a CheckBox shape in the ItemRenderer and use the states to show the tick.

    <s:GridItemRenderer>
        <s:states>
            <s:State name="normal" />
            <s:State name="hovered" />
            <s:State name="selected" />
        </s:states>
    
        <!-- checkbox graphics -->
        <s:Group width="16" height="16" horizontalCenter="0" verticalCenter="0">
            <s:Rect left="0" right="0" top="0" bottom="0">
                <s:fill>
                    <s:SolidColor color="0xffffff" />
                </s:fill>
                <s:stroke>
                    <s:SolidColorStroke color="0xa9aeb2" />
                </s:stroke>
            </s:Rect>
    
            <!-- tick, only shown when selected -->
            <s:Rect includeIn="selected" width="8" height="8" horizontalCenter="0" verticalCenter="0">
                <s:fill>
                    <s:SolidColor color="0x90b40c" />
                </s:fill>
            </s:Rect>
        </s:Group>
    </s:GridItemRenderer>
    

    This is a simplified graphic for a checkbox, but you can go grab the code from the spark CheckBoxSkin and copy/paste it in the itemrenderer. Just might have to change some state names.

    This will not deselect a single row though when you hit the CheckBox of an already selected row, unless you hold the CTRL key down. That’s the default behavior of the DataGrid component. I’m afraid you’ll have to create your own subclass of DataGrid if you want to prevent that behavior.

    Another important thing to know: setting the selected property on the itemrenderers doesn’t change the selectIndices of the DataGrid. Hence on the next commitProperties() cycle the value you set in the renderer will be overridden by the DataGrid.

    Old answer: (before edit)

    The ItemRenderer class (and thus the GridItemRenderer class too) has a selected property.
    So you could bind the checkboxes selected property to the itemrenders, like so:

    <s:CheckBox selected="{selected}" horizontalCenter="0" />
    

    You’d have to create a separate ItemRenderer class for that to work though instead of an inline one.
    If you absolutely want to go the inline way you can always override the selected setter.

    <s:GridItemRenderer>
      <fx:Script>
      <![CDATA[
          override public function set selected(value:Boolean):void {
              super.selected = cb.selected = value;
          }
      ]]>
      </fx:Script>
      <s:CheckBox id="cb" horizontalCenter="0"/>
    </s:GridItemRenderer>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why can't the data in mysql not updated when I use checkbox, I already
I have 10 checkboxes that are scattered throughout a page and if any one
I have three checkboxes like ch[0], ch[1] and ch[3] (sometimes i have more, or
Given multiple HTML checkboxes: <input type=checkbox name=catIDs value=1 /> <input type=checkbox name=catIDs value=2 />
The cell contains nothing but a checkbox. It is rather wide because of text
Currently I have a grid with a bunch of checkboxes - When a checkbox
I'm using the following snippet to create a select/deselect all checkboxes: http://www.wiseguysonly.com/2010/01/15/select-and-unselect-all-checkboxes-with-jquery/ This is
Checkboxes in HTML forms don't have implicit labels with them. Adding an explicit label
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I have several checkboxes and I am trying to take a lazy approach of

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.