2 Replies Latest reply on Jun 12, 2006 12:41 AM by Ed_Syrett

    Bug in compilation

    Ed_Syrett
      If the ComboBox appears directly on the screen, I can quite happily set it's dataprovider to an array or as in the sample code below, the result of a HTTP Service. However, if the ComboBox appears as a reusable component or as an itemEditor, the compiler cannot find the dataprovider.

      The following lines define a reusable component that uses the ProductRequest service.

      quote:


      <mx:Component id="ProductCodeEditor">
      <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"/>
      </mx:Component>



      The middle line throws an error: "Access of undefined property ProductRequest", despite the fact that ProductRequest is defined only a few lines up as a HTTPService.

      Here's the full code:

      quote:


      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      height="700" width="700"
      creationComplete="onLoad()">

      <mx:Script>
      <![CDATA[
      [Bindable]
      public var myDP:Array = [
      {label1:"P1", quantity:3},
      {label1:"P2", quantity:3}
      ];

      [Bindable]
      public var products:Array = [ {label:"P1", data:1},
      {label:"P2", data:2}, {label:"P3", data:3} ];


      public function onLoad():void
      {
      ProductsRequest.send() ;
      }
      ]]>
      </mx:Script>


      <mx:HTTPService id="ProductsRequest" url=" http://localhost:3000/lists/productlist" useProxy="false"/>

      <mx:Component id="ProductCodeEditor">
      <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"/>
      </mx:Component>

      <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"></mx:ComboBox>

      <mx:DataGrid id="myDG" dataProvider="{myDP}" variableRowHeight="true" editable="true">
      <mx:columns>
      <mx:DataGridColumn dataField="label1" headerText="Product Code" itemEditor="{ProductCodeEditor}"/>
      <mx:DataGridColumn dataField="quantity" headerText="Quantity" editorDataField="value">
      <mx:itemEditor>
      <mx:Component>
      <mx:NumericStepper stepSize="1" maximum="50"/>
      </mx:Component>
      </mx:itemEditor>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>
      quote:



      This has got to be a bug, firstly because setting the data provider for a ComboBox works in one scenario, but not in another. Secondly, I really cannot believe that Flex won't allow me to set an itemEditor that is loaded from database table. There must be a load of other apps where you want a list of products in an order. So you would show a grid where you can select a product code. As Flex offers the DataGrid where you can set an in-place editor, you would expect to be able to show a combobox with the list of products over the line you're editing. But this doesn't appear to work as I would expect given the information in the help. The code I've included here should work as that's the way the help implies it should.

      I'm disappointed that this bug exists as in-place editing in a grid like this is a fairly fundamental thing to most form-based apps. Alternatively, if this isn't supposed to work and there is some other more complex way to achieve this in-place editing, then that's just as bad as the above code should work.

      Thanks,

      Ed.