1 Reply Latest reply on Nov 18, 2007 3:55 PM by goldman-x

    itemEditEnd not firing in DataGrid

    goldman-x Level 1
      In one particular DataGrid it's not firing - all other in my app work fine. I've had another Flex developer to look at my code just in case I'm going mad or something, and he thinks it's a bug in Flex framework somewhere. I'm using Flex Builder 2.0.1 FWIW


      Here is isolated code that exhibits the same behaviour (breakpoint in onEdit event listener func does not trigger). Much of it may seem superfluous but in actual app it's neccessary in the actual app (I just tried to isolate the cause!).

      Any ideas?

      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="onInit();"
      >
      <mx:Canvas
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns:woccu="org.woccu.components.*"
      width="100%" height="100%" id="ccc"
      paddingTop="0" paddingLeft="0" paddingRight="0"
      >
      <mx:Script>
      <![CDATA[
      import mx.events.DataGridEvent;
      import mx.events.DataGridEventReason;
      import mx.collections.ArrayCollection;

      // Dataprovider
      private var _dp:ArrayCollection;

      // This will contain array (hash) accessible by bottombar or somesync
      [Bindable]
      public var bottomBar:Array;

      public function onInit():void
      {
      _dp=new ArrayCollection([{PK: 'Matt', label: "XXX", col1: 'Matthews', col2: 'XEXE', level: 1}]);;
      entrygrid.dataProvider=_dp;
      trace('init');

      }


      public function refresh():void
      {
      // TODO: check if entity ID and other props are not blank!
      // Refresh contents or somesync
      }

      // Callback function - when the data arrives
      protected function onData(result:Array):void
      {
      // Builds our dataprovider or somesync
      var tmpDPRow:Array;
      var _bottomBar:Array=new Array();
      _dp=new ArrayCollection();

      for ( var j:String in result ) {
      // First, check level. If 0 this row belongs to bottombar
      if ( result[j]["level"] == "0" ) {
      var pk:String=result[j]["PK"];
      pk=pk.replace("-","_"); // - is not valid in object ID, so we replace with _
      _bottomBar[pk]=new Object();
      _bottomBar[pk]["label"]=result[j]["label"];
      _bottomBar[pk]["value"]=result[j]["col2"];
      } else {
      // Go over fields
      tmpDPRow=new Array();
      tmpDPRow["PK"]=result[j]["PK"];
      tmpDPRow["label"]=result[j]["label"];
      tmpDPRow["col1"]=result[j]["col1"];
      tmpDPRow["col2"]=result[j]["col2"];
      _dp.addItem(tmpDPRow);
      }
      }

      // Apply bottom bar
      this.bottomBar=_bottomBar;
      // Apply all data to datagrid
      this.entrygrid.dataProvider=_dp;

      }

      public function onEdit(event:DataGridEvent):void {

      trace ('fire in the whole!');
      if ( event.reason == DataGridEventReason.CANCELLED ) {
      return;
      }

      // MUST URGENTLY UPDATE frickin database!
      this.refresh(); // Subtotals have changed - need refresh
      }


      ]]>
      </mx:Script>
      <!--
      Note the hack below: column widths are absurdly large values
      The idea is that Flex will resize down and keep the proportions
      -->
      <mx:DataGrid xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%" height="100%" showHeaders="false" itemEditEnd="onEdit(event)" id="entrygrid">
      <mx:columns>
      <mx:DataGridColumn width="0" visible="false" dataField="PK">
      </mx:DataGridColumn>
      <mx:DataGridColumn width="70000" itemRenderer="mx.controls.TextInput" editable="false" dataField="label">
      </mx:DataGridColumn>
      <mx:DataGridColumn width="15000" itemRenderer="mx.controls.TextInput" editable="false" dataField="col1">
      </mx:DataGridColumn>
      <mx:DataGridColumn width="15000" itemRenderer="mx.controls.TextInput" rendererIsEditor="true" editable="true" dataField="col2">
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>
      </mx:Canvas>
      </mx:Application>