Woops, one small correction.  If you want to preserve your 0/1, do this:

  public var value:uint;

On 7/14/06, Pan Troglodytes <[EMAIL PROTECTED]> wrote:
You may have figured out the reason by now, but if not it's because editorDataField=selected is making it look for the selected attribute on the top level component.  Unfortunately, when I added a canvas to make the centering work, the canvas because the top level.  So it gets a little more complicated.  You could break this out into separate files, but I'll just show you how to do it inline:

Put this before the DataGrid:

<mx:Component id="inlineEditor">

  <mx:Canvas width="100%" height="100%">
    <mx:Script>
      <![CDATA[
        public var value:Boolean;
      ]]>
    </mx:Script>
    <mx:CheckBox id="checkbox" selected="{Boolean(data.Sent)}" horizontalCenter="0" verticalCenter="0"/>
    <mx:Binding source="checkbox.selected" destination="value"/>
  </mx:Canvas>
</mx:Component>


And make the column like this:
<mx:DataGridColumn dataField="Sent" rendererIsEditor="true" editorDataField="value" textAlign="center" itemRenderer="{inlineEditor}"/>


This should properly expose and linkup the variable.

There might be better ways to do this.  This is just what I've come up with.


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: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com ] On Behalf Of Pan Troglodytes
Sent: Friday, July 14, 2006 2:58 PM
To: flexcoders@yahoogroups.com
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



--
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




__,_._,___

Reply via email to