Your dataField for the column with the DateField is dt but I think it should be 
date. When you change it to date though it seems the string cannot be converted 
to a date. Might need a labelFunction.


--- In flexcoders@yahoogroups.com, venkat eswar <cooler...@...> wrote:
>
> I have a problem with datefield in advanceddatagrid.The problem is when i 
> click the add button the datefield selected in the previous row will be 
> removed.How to solve this.
> The code is shown below
> 
> 
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> creationComplete="init()" layout="absolute">
>     <mx:Script>
>         <![CDATA[
>         
>         import mx.events.ListEvent;
>         import mx.controls.Alert;
>         import mx.collections.ArrayCollection;
>         
>         [Bindable]
>         private var taskCol:ArrayCollection;
>         
>         public function init():void
>         {
>             grid.initialize();
>             taskCol = new ArrayCollection();
>         }
>         
>         public function add():void
>             {
>                 var month:int = new Date().month;
>                 var date:int = new Date().date; 
>                 var year:int = new Date().fullYear;
>                 var today:String = year.toString() + "/" + month.toString() + 
> "/" + date.toString();
>                 taskCol.addItem({date: today,task: ""});
>             }
>         
>         
>         
>         ]]>
>     </mx:Script>
>     
>     
>     <mx:AdvancedDataGrid id="grid" x="136" y="141" dataProvider="{taskCol}"  
> designViewDataType="tree">
>         <mx:columns>
>             <mx:AdvancedDataGridColumn id="targetid" headerText="Target" 
> editable="false" dataField="dt" itemRenderer = "mx.controls.DateField"
>                     rendererIsEditor="true"   
> editorDataField="selectedDate"/> 
>                         
>             <mx:AdvancedDataGridColumn headerText="Column 2" dataField="task">
>             <mx:itemRenderer>
>                                  <mx:Component>
>                                  
>                                        <mx:ComboBox  tabEnabled="true"  
> selectedIndex="1"   change="data.priority=selectedItem;" 
> text="{data.priority}">
>                                             <mx:dataProvider>
>                                                <mx:ArrayCollection>
>                                                    <mx:String>High</mx:String>
>                                                    
> <mx:String>Medium</mx:String>
>                                                    <mx:String>Low</mx:String>
>                                                    
>                                                 </mx:ArrayCollection>
>                                                 
>                                              </mx:dataProvider>
>                                              
>                                        </mx:ComboBox>
>                                  </mx:Component>
>                                  
>                               </mx:itemRenderer>
>                               
>                         </mx:AdvancedDataGridColumn>    
>         </mx:columns>
>     </mx:AdvancedDataGrid>
>     <mx:Button x="396" y="250" label="Add" click="add()"/>
>     
> </mx:Application>
>

Reply via email to