package com.theriabook.controls {
import mx.controls.CheckBox;
import mx.controls.dataGridClasses.DataGridListData;
public class CheckBox extends mx.controls.CheckBox {
public var onValue:Object = 1;
public var offValue:Object = 0;
public function set value(o:Object) :void {
selected = (o == onValue);
}
public function get value():Object {
return selected?onValue:offValue;
}
override public function set data(item:Object):void {
super.data = "">
if( item!=null )
value = item[DataGridListData(listData).dataField];
}
}
}
... itemRenderer="com.theriabook.controls.CheckBox"
rendererIsEditor="true" editorDataField="value">
If you think you would not be able to reuse CheckBox class or would like in place definition in the same file please consider code above nevertheless and use className on component tag so the implementation is clean and it is easy to refactor when the code review / second generation of developers come
Anatole:
You seem pretty knowledgable about Flex. Can you find any problem with the casting approach I posted? Seems like a bit less of a hassle than defining an external class.
On 7/14/06, Anatole Tartakovsky < [EMAIL PROTECTED]> wrote:You can use this class as your item renderer
package com.theriabook.controls {
import mx.controls.CheckBox;
import mx.controls.dataGridClasses.DataGridListData;
public class CheckBox extends mx.controls.CheckBox {
public var onValue:Object = 1;
public var offValue:Object = 0;
public function set value(o:Object) :void {
selected = (o == onValue);
}
public function get value():Object {
return selected?onValue:offValue;
}
override public function set data(item:Object):void {
super.data = "">
if( item!=null )
value = item[DataGridListData(listData).dataField];
}
}
}
and these attributes on the datagridcolumn... itemRenderer="com.theriabook.controls.CheckBox"
rendererIsEditor="true" editorDataField="value">
Styling and dealing with settings controls defaults without drop-in itemRenderer requires subclassing of DataGridColumn and it's ClassFactory - described in details in upcoming Flex book, but would take about 5 pages to explain. Nevertheless, the case is "classical, will try to respond via components forum
Thank you,
Anatole
On 7/14/06, Shannon Hicks < [EMAIL PROTECTED]> wrote:Pan-I tried this, and the checkbox shows up properly checked/unchecked.Now, I get this error when I change the state:ReferenceError: Error #1069: Property selected not found on flexComponents.editMouse_inlineComponent1 and there is no default value.Shan
From: [email protected] [mailto: [email protected] ] On Behalf Of Pan Troglodytes
Sent: Friday, July 14, 2006 2:58 PM
To: [email protected]
Subject: [Junk E-Mail - MED] Re: [flexcoders] dataGrid drop-in itemRenderer/Editor
Flash knows how to convert 0/1 to Boolean, it just doesn't always know WHEN to do it. To answer both your questions, here is a modified version of the help example:
<?xml version="1.0"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" height="700" width="700">
<mx:Script>
<![CDATA[
[Bindable]
public var myDP:Array = [
{label1:"Order #2314", contact:"John Doe", quant:3, solddate:new Date(2005, 0, 1), Sent:1},
{label1:"Order #2315", contact:"Jane Doe", quant:3, solddate:new Date(2005, 0, 5), Sent:0}];
]]>
</mx:Script>
<mx:DataGrid id="myDG" dataProvider="{myDP}" variableRowHeight="true" width="500" height="250" editable="true">
<mx:columns>
<mx:DataGridColumn dataField="label1" headerText="Order #" editable="false"/>
<mx:DataGridColumn dataField="quant" headerText="Quantity" itemEditor="mx.controls.NumericStepper " editorDataField="value"/>
<mx:DataGridColumn dataField="solddate" headerText="Date" itemRenderer=" mx.controls.DateField" rendererIsEditor="true" editorDataField="selectedDate"/>
<mx:DataGridColumn dataField="Sent" rendererIsEditor="true" editorDataField="selected" textAlign="center">
<mx:itemRenderer>
<mx:Component>
<mx:Canvas width="100%" height="100%">
<mx:CheckBox selected="{Boolean(data.Sent)}" horizontalCenter="0" verticalCenter="0"/>
</mx:Canvas>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>On 7/14/06, Shannon Hicks < [EMAIL PROTECTED]> wrote:I have a dataGrid where I'd like to use a checkbox drop-in renderer/editor. My query returns two columns: name [varchar(45)] and featured [smallint]. Featured returns either 1 or 0.Now, in the dataGrid, my featured column looks like this:<mx:DataGridColumn headerText="Featured Image" dataField="featured" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true" editorDataField="selected" textAlign="center"/>First off... The checkbox doesn't show checked/unchecked according to the value of featured (1 or 0). Do I need to somehow convert 1 & 0 to boolean values? Isn't flash supposed to do this automatically?Secondly... The checkbox isn't centered. I'm not sure how to do that, as silly as it sounds.Shan
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.0/388 - Release Date: 7/13/2006
--
Jason--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.0/388 - Release Date: 7/13/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.0/388 - Release Date: 7/13/2006--
Jason
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
![]()
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
- Re: [Junk E-Mail - MED] Re: [flexcoders] dataGrid drop... Anatole Tartakovsky
- RE: [Junk E-Mail - LOW] Re: [Junk E-Mail - MED] R... Shannon Hicks
- Re: [Junk E-Mail - LOW] Re: [Junk E-Mail - ME... Anatole Tartakovsky
- RE: [Junk E-Mail - LOW] Re: [Junk E-Mail ... Shannon Hicks
- Re: [Junk E-Mail - LOW] Re: [Junk E-M... Jeremy Lu
- Re: [flexcoders] dataGrid drop-i... Tim Hoff
- Re: [flexcoders] dataGrid dr... Anatole Tartakovsky
Reply via email to

