Highlighted

Iterate through ItemRenderer Checkboxes in a DataGrid

Community Beginner ,
May 02, 2019

Copy link to clipboard

Copied

Hi,

I have a datagrid with checkboxes in the first third and fourth columns. Each of these checkboxes is to be assigned a value from the data source that it is bound to. My task is simple:

1) Iterate through all the DataGrid rows, 2) see if the checkbox is checked, and 3) get the checkbox value.

Could someone please post a working example for me?

Thank you.

This is how the DataGrid looks:

And here's the code for the checkbox column:

<mx:DataGridColumn dataField="downloadIndicator"

   editable="true"

   editorDataField="selected"

   rendererIsEditor="false"

   width="{this.width*.05}"   

   sortable="false">

<mx:headerRenderer>

<mx:Component>

<mx:HBox horizontalAlign="center">

<mx:CheckBox

click="headerDownload_clickHandler(event)"

toolTip="{ResourceUtil.getResourceValue('allColors.downloadToolTip', parentDocument.selectedCompany.name,'strings',Util.getLocale())}"

selected="{parentDocument.chkAllSelected}">

<mx:Script>

<![CDATA[

import com.phototype.myinkiq.model.vos.dtos.AllColorsDto;

import com.phototype.myinkiq.model.vos.dtos.ColorsDto;

import com.phototype.util.ResourceUtil;

import com.phototype.util.Util;

protected function headerDownload_clickHandler(event:MouseEvent):void

{

if (event.currentTarget!=null) {

parentDocument.chkAllSelected = event.currentTarget.selected;

var i:int=0;

var color:AllColorsDto = null;

for (i=0; i<parentDocument.colorsDtoCollection.length;i++) {

color = parentDocument.colorsDtoCollection.getItemAt(i) as AllColorsDto;

if (color.r!=null)

color.downloadIndicator = event.currentTarget.selected;

else

color.downloadIndicator = false;

}

}

}

]]>

</mx:Script>

</mx:CheckBox>

</mx:HBox>

</mx:Component>

</mx:headerRenderer>

<mx:itemEditor>

<mx:Component>

<itemRenderers:CheckBoxRenderer selected="{data.downloadIndicator}"

enabled="{data.r!=null}"/>

</mx:Component>

</mx:itemEditor>

<mx:itemRenderer>

<mx:Component>

<itemRenderers:CheckBoxRenderer selected="{data.downloadIndicator}"

enabled="{data.r!=null}"

/>

</mx:Component>

</mx:itemRenderer>

</mx:DataGridColumn>

TOPICS
ActionScript

Views

162

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Iterate through ItemRenderer Checkboxes in a DataGrid

Community Beginner ,
May 02, 2019

Copy link to clipboard

Copied

Hi,

I have a datagrid with checkboxes in the first third and fourth columns. Each of these checkboxes is to be assigned a value from the data source that it is bound to. My task is simple:

1) Iterate through all the DataGrid rows, 2) see if the checkbox is checked, and 3) get the checkbox value.

Could someone please post a working example for me?

Thank you.

This is how the DataGrid looks:

And here's the code for the checkbox column:

<mx:DataGridColumn dataField="downloadIndicator"

   editable="true"

   editorDataField="selected"

   rendererIsEditor="false"

   width="{this.width*.05}"   

   sortable="false">

<mx:headerRenderer>

<mx:Component>

<mx:HBox horizontalAlign="center">

<mx:CheckBox

click="headerDownload_clickHandler(event)"

toolTip="{ResourceUtil.getResourceValue('allColors.downloadToolTip', parentDocument.selectedCompany.name,'strings',Util.getLocale())}"

selected="{parentDocument.chkAllSelected}">

<mx:Script>

<![CDATA[

import com.phototype.myinkiq.model.vos.dtos.AllColorsDto;

import com.phototype.myinkiq.model.vos.dtos.ColorsDto;

import com.phototype.util.ResourceUtil;

import com.phototype.util.Util;

protected function headerDownload_clickHandler(event:MouseEvent):void

{

if (event.currentTarget!=null) {

parentDocument.chkAllSelected = event.currentTarget.selected;

var i:int=0;

var color:AllColorsDto = null;

for (i=0; i<parentDocument.colorsDtoCollection.length;i++) {

color = parentDocument.colorsDtoCollection.getItemAt(i) as AllColorsDto;

if (color.r!=null)

color.downloadIndicator = event.currentTarget.selected;

else

color.downloadIndicator = false;

}

}

}

]]>

</mx:Script>

</mx:CheckBox>

</mx:HBox>

</mx:Component>

</mx:headerRenderer>

<mx:itemEditor>

<mx:Component>

<itemRenderers:CheckBoxRenderer selected="{data.downloadIndicator}"

enabled="{data.r!=null}"/>

</mx:Component>

</mx:itemEditor>

<mx:itemRenderer>

<mx:Component>

<itemRenderers:CheckBoxRenderer selected="{data.downloadIndicator}"

enabled="{data.r!=null}"

/>

</mx:Component>

</mx:itemRenderer>

</mx:DataGridColumn>

TOPICS
ActionScript

Views

163

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 02, 2019 0
kglad LATEST
Adobe Community Professional ,
May 08, 2019

Copy link to clipboard

Copied

i could help you if you used flash/animate, but that looks like flash builder or like some other non-flash/non-animate authoring tool was used.

my guess is others checking this forum feel the same because no one's responded and it's been almost one week since you posted.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 08, 2019 0