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

    Compilation error with dataProvider attribute

      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:


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

      public var myDP:Array = [
      {label1:"P1", quantity:3},
      {label1:"P2", quantity:3}

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

      public function onLoad():void
      ProductsRequest.send() ;

      <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:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"></mx:ComboBox>

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

      I get a complation error on the following line


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

      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.


      27 <mx:HTTPService id="ProductsRequest" url=" http://localhost:3000/lists/productlist" useProxy="false"/>
      29 <mx:Component id="ProductCodeEditor">
      30 <mx:ComboBox dataProvider="{ProductsRequest.lastResult.products.product}" labelField="name"/>
      31 </mx:Component>
      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?