0 Replies Latest reply on Feb 7, 2008 9:13 AM by bitwyse

    Double Click Vs. Change events in datagrid

    bitwyse Level 1
      Hi All, I'm hoping someone can see something I'm missing here . I use the Cairngorm framework for a project that I am developing. I have the basic shell of the application working quite well. I am trying to add some details to the code now and am having some strange results. I have a page that displays a datagrid . My datagrid has both a double click handler as well as a change handler. My double click handler first calls the change handler in order to fetch some data from a web service behind the scenes. The problem is this. When I load the datagrid and double click on an entry the resulting data doesn't show up. However, when I single click an entry in the datagrid then double click it, the resulting data shows up. That doesn't make sense to me. Below is the code for the data grid and the change and doubleclic handlers. Any ideas would be greatly appreciated.

      <psc:MyDataGrid id="dataGridProjects"
      dataProvider="{model.getProjectControls.arrayOfProjectControlVOs}"
      contextMenu="{myContextMenu}"
      doubleClickEnabled="true"
      doubleClick="viewDetailHandler( event )"
      change="getProjectInformation()"
      MyViewCurrentEvent="viewDetailHandler( event )"
      MyEditCurrentEvent="editCurrentHandler( event )"
      MyDeleteCurrentEvent="viewDetailHandler( event )">
      <psc:columns>
      <mx:DataGridColumn headerText="Prj. #" dataField="projectID" width="80"/>
      <mx:DataGridColumn headerText="Prj. Name" dataField="projectName" width="250"/>
      <mx:DataGridColumn headerText="Status" dataField="projectStatus" width="50"/>
      <mx:DataGridColumn headerText="Start" dataField="projectStartDate" width="80" sortCompareFunction="compareProjectStartDates"/>
      <mx:DataGridColumn headerText="Comp. #" dataField="projectCompanyNumber" width="60"/>
      <mx:DataGridColumn headerText="Comp. Name" dataField="projectCompanyName" width="250"/>
      <mx:DataGridColumn width="20" itemRenderer="com.psc.eis.view.MyDGViewRenderer"/>
      <mx:DataGridColumn width="20" itemRenderer="com.psc.eis.view.MyDGEditRenderer"/>
      <mx:DataGridColumn width="20" itemRenderer="com.psc.eis.view.MyDGDeleteRenderer"/>
      </psc:columns>
      </psc:MyDataGrid>

      private function getProjectInformation() : void
      {
      if( model.getDeliverables.arrayOfDeliverableVOs )
      {
      model.getDeliverables.arrayOfDeliverableVOs.removeAll();
      }

      if( model.getTasks.arrayOfTaskVOs )
      {
      model.getTasks.arrayOfTaskVOs.removeAll();
      }

      if( model.getMailInDocuments.arrayOfMailInDocumentVOs )
      {
      model.getMailInDocuments.arrayOfMailInDocumentVOs.removeAll();
      }

      var event : GetProjectDetailsEvent = new GetProjectDetailsEvent();
      event.data = dataGridProjects.selectedItem;
      CairngormEventDispatcher.getInstance().dispatchEvent( event );

      var event2 : GetMailInDocumentsEvent = new GetMailInDocumentsEvent();
      event2.data = dataGridProjects.selectedItem;
      CairngormEventDispatcher.getInstance().dispatchEvent( event2 );
      }

      public function viewDetailHandler( event:Object ) : void
      {
      getProjectInformation();
      model.workflowState = ModelLocator.VIEWING_PROJECT_DETAIL;
      }