3 Replies Latest reply on Aug 17, 2006 3:34 PM by papalarge

    Compilation error with dataProvider attribute

    Ed_Syrett
      My objective is to have a ComboBox itemEditor for a column in a DataGrid. This will get used in a number of places in our app, for example to add an order line to an order. We would want the ComboBox to be populated with the list of available products, and Flex goes most of the way to providing that functionality. But I get a compilation error on a line that I would expect to work. Here's the full sample:

      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>



      I get a complation error on the following line

      quote:


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



      The error message is "Access of undefined property ProductsRequest"

      However, the other <mx:ComboBox> definition compiles and works fine. In other words, in the sample code (shown again below) we have two <mx:ComboBox> definitions with the same dataProvider definition. The one on line 33 compiles and works, the other doesn't, and the only difference is that one of them is within a <mx:Component> declaration.

      quote:


      27 <mx:HTTPService id="ProductsRequest" url=" http://localhost:3000/lists/productlist" useProxy="false"/>
      28
      29 <mx:Component id="ProductCodeEditor">
      30 <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"/>
      31 </mx:Component>
      32
      33 <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"></mx:ComboBox>



      I really can't believe that this behaviour is by design. If it is, could somebody tell me what this design is, and how I am supposed to populate a combobox with product codes in a grid?

      Thanks,

      Ed.