Use callLater to invoke a method : CallLater « Data Model « Flex






Use callLater to invoke a method

Use callLater to invoke a method
       
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    
      import mx.collections.ArrayCollection;
          
      [Bindable] private var gridArrayCollection:ArrayCollection = new ArrayCollection();

      private function addGridItem(event:Event):void 
      {
        gridArrayCollection.addItem(NameInput.text);
        callLater(selectNewRow);
      }
        
      private function selectNewRow():void 
      {
        nameGrid.selectedIndex = nameGrid.rowCount;
      }
        
  
  </mx:Script>
    <mx:VBox width="100%" height="100%">
        <mx:DataGrid id="nameGrid" dataProvider="{gridArrayCollection}" width="100%" height="100%">
          <mx:columns>
            <mx:DataGridColumn dataField="firstName" headerText="First Name"/>
          </mx:columns>
        </mx:DataGrid>
        <mx:Label text="Name:" />
        <mx:TextInput id="NameInput" />
        <mx:Button label="Enter New Item" click="addGridItem(event)"/>
  </mx:VBox>
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Use CallLater function to Add Item to DataGridUse CallLater function to Add Item to DataGrid
2.uses the callLater() method to open multiple browser windows with the navigateToURL() methoduses the callLater() method to open multiple browser windows with the navigateToURL() method