<x-tad-smaller>All,
I've just signed up for the list hoping to get some help on some Flex items
and also contribute any way I can. I've been developing in ColdFusion for 6
years and recently started integrating Flex 2.0 development with my CF
development. Anyhow, enough about me, on to my question. I'm attempting
to setup a custom ItemRenderer (a checkbox) in multiple DataGrid columns.
I've successfully done this with one column already but when trying to make
my custom ItemRenderer generic enough so it can be used across multiple
columns I've run into issues. Below is snippet of my DataGrid code as well
as the code for the custom ItemRenderer. The behavior I'm seeing is selecting
the checkbox in the "groupOwner" column affects - in odd ways - the checboxes
in the other columns using the same renderer. I'm pretty sure it's because all
the columns reference the same name for the editorDataField attribute. But,
I'm not sure how to make the value of that attribute different across columns
and still use the same custom ItemRenderer.
Can anyone point me in the right direction?
// Custom Checkbox ItemRenderer
// NOTE: Much of the code in the overridden method is speculative and
// probably all wrong.
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.controls.Alert;
import mx.core.Application;
[Bindable]
public var cbSelected:Boolean;
override public function set data(value:Object):void {
if (value != null) {
super.data = value;
if (value.BISOWNER != null) {
cbSelected = value.BISOWNER;
} else if (value.BISEXPORTED != null) {
mx.controls.Alert.show("bisexported");
cbSelected = value.BISEXPORTED;
} else if (value.ALLOWEDITS != null) {
cbSelected = value.ALLOWEDITS;
} else if (value.BISVINDECODE != null) {
cbSelected = value.BISVINDECODE;
}
}
dispatchEvent( new FlexEvent(FlexEvent.DATA_CHANGE));
}
]]>
</mx:Script>
<mx:CheckBox id="cbGeneric" selected="{cbSelected}" click="cbSelected = cbGeneric.selected" updateComplete="cbSelected = cbGeneric.selected"/>
</mx:VBox>
// DataGrid Snippet
<mx</x-tad-smaller>:D<x-tad-smaller>ataGrid id="dgGroupingSetup" dataProvider="{groupingSetup}" itemEditEnd="processDGEdit(event)" width="100%" editable="true" height="246">
<mx:columns>
<mx</x-tad-smaller>:D<x-tad-smaller>ataGridColumn id="groupID" headerText="Group ID" dataField="INVENTORYGROUPINGID" editable="false" width="60"/>
<mx</x-tad-smaller>:D<x-tad-smaller>ataGridColumn id="groupOwner" headerText="Group Owner" dataField="BISOWNER" itemRenderer="ItemRenderers.GenericCheckboxRenderer" rendererIsEditor="true" editorDataField="cbSelected" width="85"/>
<mx</x-tad-smaller>:D<x-tad-smaller>ataGridColumn id="exportData" headerText="Export Data" dataField="BISEXPORTED" itemRenderer="ItemRenderers.GenericCheckboxRenderer" rendererIsEditor="true" editorDataField="cbSelected" width="80"/>
<mx</x-tad-smaller>:D<x-tad-smaller>ataGridColumn id="allowEdits" headerText="Allow Edits" dataField="ALLOWEDITS" itemRenderer="ItemRenderers.GenericCheckboxRenderer" rendererIsEditor="true" editorDataField="cbSelected" width="75"/>
<mx</x-tad-smaller>:D<x-tad-smaller>ataGridColumn id="vinDecode" headerText="VIN Decode" dataField="BISVINDECODE" itemRenderer="ItemRenderers.GenericCheckboxRenderer" rendererIsEditor="true" editorDataField="cbSelected" width="80"/></x-tad-smaller>
</mx:columns>
</mx:DataGrid>
| Aaron West
| aaron AT trajiklyhip DOT com
| http://www.trajiklyhip.com/blog/
| Certified Advanced Adobe ColdFusion MX 7 Developer
| Certified Macromedia FlashMX Developer
| Adobe Community Expert
- [flexcoders] Reusing Custom ItemRenderer in a DataGrid Aaron West

