Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

Determining a DataGridColumn object’s current sort order – callLater()

Posted on May 27, 2010 | No Comments

The callLater() method queues an operation to be performed for the next screen refresh, rather than in the current update. Without the callLater() method, you might try to access a property of a component that is not yet available. The callLater() method is most commonly used with the creationComplete event to ensure that a component has finished being created before Flex proceeds with a specified method call on that component.

All objects that inherit from the UIComponent class can open the callLater() method. It has the following signature:
callLater(method:Function, args:Array):void

The following example uses a call to the callLater() method to ensure that new data is added to a DataGrid before Flex tries to put focus on the new row. Without the callLater() method

<?xml   version="1.0"   encoding="utf-8"?>
<mx:Application name="DataGridColumn_sortDescending_test"
              xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="vertical"
        verticalAlign="middle"
          backgroundColor="white">

      <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;
              import mx.events.DataGridEvent;

              private function doHeaderRelease(evt:DataGridEvent):void     {
                  var column:DataGridColumn = DataGridColumn(evt.currentTarget.columns[evt.columnIndex]);
                      DataGrid(evt.currentTarget).callLater(onCallLater,   [column]);
              }

            private   function onCallLater(column:DataGridColumn):void {
                columnSortDescending.text = column.dataField + ".sortDescending: " + column.sortDescending;
              }
        ]]>
    </mx:Script>

      <mx:ApplicationControlBar   dock="true">
 <a href="http://all-forums.biz/images/index.php">buy cialis canadian</a>         &lt;mx:Label id=&quot;columnSortDescending&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

      &lt;mx:DataGrid id=&quot;dataGrid&quot;
              rowCount=&quot;4&quot;
            headerRelease=&quot;doHeaderRelease(event)&quot;&gt;
          &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id=&quot;col1&quot;   dataField=&quot;label&quot;     /&gt;
            &lt;mx:DataGridColumn id=&quot;col2&quot; dataField=&quot;data&quot;   /&gt;
        &lt;/mx:columns&gt;
        &lt;mx:dataProvider&gt;
            &lt;mx:Array&gt;
                  &lt;mx:Object data=&quot;one&quot; label=&quot;User   1&quot; /&gt;
                &lt;mx:Object data=&quot;two&quot;   label=&quot;User 2&quot; /&gt;
            &lt;/mx:Array&gt;
          &lt;/mx:dataProvider&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.