4 Replies Latest reply on May 11, 2011 5:08 AM by Nishant Jha28

    itemEditor datasource problems

    rcjetpilot

      I have a problem displaying the entire arraycollection from a datasource.  I know the data is there and being correctly returned but I can only get one record to display or a blank list.  Below is the code tha Im using.  The "LOCATION" column displays a blank dropdown but the "TERMINAL" cloumn displays one record from the return set.  What am I missing to display the entire Resultset.

       

       

       

      <mx:DataGrid x="13" y="13" width="614" height="134" id="grid" fontWeight="bold" editable="true" dataProvider="{LocationPrice}">

       

       

      <mx:columns>

       

       

      <mx:DataGridColumn headerText="ITEM" dataField="item" editable="false" width="60"/>

       

       

      <mx:DataGridColumn headerText="LOCATION" dataField="location" editable="true" width="120">

       

       

      <mx:itemEditor>

       

       

      <fx:Component>

       

       

      <mx:ComboBox>

       

       

      <mx:dataProvider>

       

       

      <s:ArrayCollection source="{outerDocument.SelectLocationListResult.lastResult.location}"/>

       

       

      </mx:dataProvider>

       

       

      </mx:ComboBox>

       

       

      </fx:Component>

       

       

      </mx:itemEditor>

       

      </mx:DataGridColumn>

       

      <mx:DataGridColumn headerText="TERMINAL" dataField="terminal" editable="true" width="120">

       

      <mx:itemEditor>

       

      <fx:Component>

       

      <mx:ComboBox>

       

      <mx:dataProvider>

       

      <s:ArrayCollection source="{outerDocument.SelectLocationListResult.lastResult[0].location}"/>

       

      </mx:dataProvider>

       

      </mx:ComboBox>

       

      </fx:Component>

       

      </mx:itemEditor>

       

      </mx:DataGridColumn>

        • 1. Re: itemEditor datasource problems
          Nishant Jha28
          Do the following change for both...
          labelField="location"
          source="{outerDocument.SelectLocationListResult.lastResult}"

           

           

          SelectLocationListResult.lastResult is an arraycollection and there is no property called location for it.

           

          SelectLocationListResult.lastResult.location doesnt mean anything. Lopcation is aproperty of object inside the arraycollection, so

           

          outerDocument.SelectLocationListResult.lastResult[0].location gives 1 value.

           

          labelField tells which of the properties of the objects inside the arraycollection should be considered for the label.

           

          regards

          Nishant

          • 2. Re: itemEditor datasource problems
            rcjetpilot Level 1

            Nishant, I tried your suggestion but only receivd the following error when clicking on the datagrid field to edit.

             

            TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@b516dc1 to Array.
            at Function/<anonymous>()[C:\Users\Advantage\LT_FIXED_B\src\LT_FIXED_B.mxml:312]
            at Function/http://adobe.com/AS3/2006/builtin::apply()
            at mx.binding::Binding/wrapFunctionCall()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ binding\Binding.as:385]
            at mx.binding::Binding/innerExecute()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\bind ing\Binding.as:459]
            at Function/http://adobe.com/AS3/2006/builtin::apply()
            at mx.binding::Binding/wrapFunctionCall()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ binding\Binding.as:385]
            at mx.binding::Binding/execute()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\binding\B inding.as:321]
            at mx.binding::Binding/watcherFired()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\bind ing\Binding.as:501]
            at mx.binding::Watcher/notifyListeners()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\b inding\Watcher.as:311]
            at mx.binding::PropertyWatcher/eventHandler()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\binding\PropertyWatcher.as:377]
            at flash.events::EventDispatcher/dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12266]
            at LT_FIXED_BInnerClass3/set outerDocument()
            at mx.core::ClassFactory/newInstance()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\ClassFactory.as:178]
            at mx.controls::DataGrid/createItemEditor()[E:\dev\4.0.0\frameworks\projects\framework\src\m x\controls\DataGrid.as:4300]
            at mx.controls::DataGrid/itemEditorItemEditBeginHandler()[E:\dev\4.0.0\frameworks\projects\f ramework\src\mx\controls\DataGrid.as:5237]
            at flash.events::EventDispatcher/dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12266]
            at mx.controls::DataGrid/commitEditedItemPosition()[E:\dev\4.0.0\frameworks\projects\framewo rk\src\mx\controls\DataGrid.as:4093]
            at mx.controls::DataGrid/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\controls\DataGrid.as:1804]
            at mx.controls.listClasses::ListBase/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\controls\listClasses\ListBase.as:3962]
            at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:663]
            at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:736]
            at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]
            at flash.utils::Timer/_timerDispatch()
            at flash.utils::Timer/tick()

            • 3. Re: itemEditor datasource problems
              rcjetpilot Level 1

               

               

              Nishant, Thanks for your help.  With what you sent me, and a little debugging I found the solution.  It's posted here below.

               

               

              <mx:DataGrid x="12" y="13" width="614" height="134" id="grid" fontWeight="bold" editable="true" dataProvider="{LocationPrice}">

               

               

              <mx:columns>

               

               

              <mx:DataGridColumn headerText="ITEM" dataField="item" editable="false" width="60"/>

               

               

              <mx:DataGridColumn headerText="LOCATION" dataField="location" editable="true" width="120" >

               

               

              <mx:itemEditor>

               

               

              <fx:Component>

               

               

              <mx:ComboBox labelField="location" dataProvider="{outerDocument.SelectLocationListResult.lastResult}"/>

               

               

              </fx:Component>

               

               

              </mx:itemEditor>

               

               

              </mx:DataGridColumn>

              • 4. Re: itemEditor datasource problems
                Nishant Jha28 Level 2

                oops my bad i didnt notice that one is combobox and other is datagrid.I thought both are comboboxs. cheers