2 Replies Latest reply on Mar 3, 2010 2:30 AM by RonnieCR7

    How to delete the contents of a Datagrid?

    RonnieCR7 Level 1

      Hi all,

      I wanna delete the contents of a datagrid and be able to display the contents again as needed.

      I have two datefield choosers, two buttons. One button to show the datagrid log. Other button to clear the datagrid.

       

           <mx:HBox width="100%" height="100%" >
             <mx:Label text="From"/>
             <mx:DateField id="dateFrom" showToday="true" enabled="true"
              formatString="MM/DD/YYYY"
              disabledRanges="{[new Date(), {rangeStart: new Date()}]}"/>
             <mx:Label text="To"/>
             <mx:DateField id="dateTo" showToday="true" enabled="true"
              formatString="MM/DD/YYYY"
              disabledRanges="{[new Date(), {rangeStart: new Date()}]}"/>
        
             <mx:Button id="btn1" label="Show Error Log" click="getErrorLog()"/>
         
             <mx:Button id="btn2" label="Clear All" click="clear()"/>
            </mx:HBox>

       

      But once i delete the contents of the datagrid, i am not able to load the data again. I delete the content using the following function:

       

      private function clear():void{
        
         dateFrom.text = "";
         dateTo.text = "";
         var cols:Array = errorLogTable.columns;
         var size:int = errorLogTable.columnCount;
         cols.splice(0,size);
         errorLogTable.columns = cols;  
        
        }

       

      errorLogTable is the id of my datagrid.