2 Replies Latest reply on Apr 15, 2010 9:31 AM by Flex harUI

    Datagrid itemrenderer and itemeditor

    niksk

      Hi Everyone,

       

      I have one Datagrid with one column as Checkbox item renderer and other column as TextArea item editor.

       

      Now my problem is communication between item editor and item renderer.

       

      When user enter text in TextArea the Checkbox should get selected automatically.

       

      Please give me some idea around it.

       

      Thanks

      Nikhil Khurana

        • 1. Re: Datagrid itemrenderer and itemeditor
          Flex harUI Adobe Employee

          It depends on how you set up your checkbox renderer.  Is it reflecting

          selectedItems or a field in the dataprovider?

          • 2. Re: Datagrid itemrenderer and itemeditor
            niksk Level 1

            Yes it is reflecting my dataprovider as i need to change some records after selection of some fields.

             

            Here is some snippet of my code:

             

            Column for Checkbox in datagrid:

             

            <mx:DataGridColumn headerText="Impacted" itemRenderer="com.basepin.view.components.CenteredCheckBox"  rendererIsEditor="true" editorDataField="selected" dataField="selected"/>

             

            Column for TextArea:

             

            <mx:DataGridColumn headerText="Room" dataField="level_room" width="250" textAlign="center">

                 <mx:itemEditor >

                      <mx:Component>

                           <mx:TextArea  wordWrap="true" borderStyle="none" editable="true"  maxChars="45"   />

                      </mx:Component>

                 </mx:itemEditor>

            </mx:DataGridColumn>

             

             

            Bindable ArrayCollection:

             

            [Bindable]

            public var _acProjectIssueLevels:ArrayCollection;

            and this is directly given to dataprovider.
            For Checkbox Itemrenderer I am using mxml file:
            <?xml version="1.0" encoding="utf-8"?>
            <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"  width="100%" height="35" horizontalAlign="center" verticalAlign="middle">
                      override public function set data(value:Object):void
                        {
                            //super.data = value;
                           // not sure of the details on when or why, but sometimes this method is passed a null value
                            if(value == null)
                            return;
                            _data = value;
                            cbx.selected = Boolean(_data.selected);
                          }
               
                     override public function get data():Object
                     {
                      if (_data != null)
                            return _data;
                      return null;
                    }
            private function updateSelected():void
            {
            _data.selected = cbx.selected;
            }
            private var _data:Object;
            public function get selected():Object
            {
                 return Object(_data.selected);
            }
            ]]>
            </mx:Script>
            <mx:CheckBox  id="cbx" width="14" change="updateSelected()" />
            </mx:HBox>