4 Replies Latest reply on Sep 5, 2009 9:09 PM by rickcr

    Confusion: related to asynch load of DataGrid or using custom DataGridColumn  ?

    rickcr Level 1

      First if I'm using BlazeDS and I'm getting back a collection of Employees from my remote call. When I decide to try to use an implementation of  DataGridColumn as described here http://www.switchonthecode.com/tutorials/nested-data-in-flex-datagrid-by-extending-datagri dcolumn I'm getting a null pointer exception in the call to itemToLabel(data:Object):String - 'data' is null. Not sure why. But even though I need to solve this problem, I'm curious about why I don't even see the server side method getting hit?

       

      For example, when NOT using the custom DataGridColumn the below works fine and I'll see logging of the call to 'getEmployees' take place:

       

      Working:

       

      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:comp="components.*"
          creationComplete="init()" >
         
          <mx:Script>
          <![CDATA[
         
          [Bindable]
          private var employees:ArrayCollection;

       

          private function init():void {
              delegate.getEmployees();   
          }
          private function resultGetEmployeesSuccess(event:ResultEvent):void {
               employees = event.result as ArrayCollection;
          }
         
         
          ]]>
          </mx:Script>
              <mx:RemoteObject id="delegate" destination="flexDelegate" fault="faultHandler(event)">
                  <mx:method name="getEmployees" result="resultGetEmployeesSuccess(event)"/>
              </mx:RemoteObject>
         
              <mx:DataGrid id="empsID" dataProvider="{employees}" verticalScrollPolicy="on"
                          height="60%" itemClick="selectEmployee(event)">
                  <mx:columns>
                      <mx:DataGridColumn id="idCol" dataField="id"  headerText="ID" draggable="false"/>
                      <mx:DataGridColumn id="firstName" dataField="firstName" headerText="First" draggable="false"/>
                      <mx:DataGridColumn id="lastName" dataField="lastName"   headerText="Last" draggable="false"/>
                      <mx:DataGridColumn id="age" dataField="age" headerText="Age" draggable="false" />
                  </mx:columns>
              </mx:DataGrid>

       

      However when I change the above to include

       

      <comp:DataGridColumnNested dataField="department.name"  headerText="Department" />

       

      I DO NOT see the server call to "getEmployees" even hit - this has me stumped. How can it be trying to render DataGridColumNested before it even finished loading the employees? Is it because of the asynch call to the remote object? If so, what's the best way to make sure the grid doesn't even try to load until it "really" has data?

       

      Thanks