2 Replies Latest reply: Jul 4, 2014 2:01 PM by pauland RSS

    DataGrid fails when only one record is retrieved from Web Service (token.count?)

    Michelle5002

      I have a combo box which contains master records.   When I select an item from the combo box, I then ask the web service for the detail records associated with the selected combobox item.  I am doing this so I get the latest and most uptodate information.
         And then populate the results in a List which is bound to the datagrid.    Everything works fine until I select a master record which only has one detail record.  And then the app crashes.

       

      It has been suggested that I check to see how many records are in the results and if there is only one record then add the record myself.   Okay, fine.   How do I do that?

       

      I am using Flashbilder 4.5

       

      Datagrid:

      <code>

      [Bindable]protected var placesList:ArrayCollection = new ArrayCollection();

       

      protected function peopleCB_changeHandler(event:IndexChangeEvent):void
      {
      if (personDto.id > 0)
      {
      getPlacesResult.token = sampleBean.getPlaces(personDto.id);
      }
      }
      protected function getPlacesResult_resultHandler(event:ResultEvent):void
      {
      placesList = getPlacesResult.lastResult;
      }

      <s:DataGrid id="DG" x="10" y="160" width="900" height="150"

      editable="true"

       

      dataProvider="{placesList}"

      creationComplete="DG_creationCompleteHandler(event)">

       

      </code>


      Error:


      TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@689a4c1 to mx.collections.IList.

      at Function/<anonymous>()[D:\LunaFlex\db2SampleWeb\src\db2SampleWeb.mxml:133]

      at Function/http://adobe.com/AS3/2006/builtin::apply()

      at mx.binding::Binding/wrapFunctionCall()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\ binding\Binding.as:385]

      at mx.binding::Binding/innerExecute()[E:\dev\4.5.1\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.5.1\frameworks\projects\framework\src\mx\ binding\Binding.as:385]

      at mx.binding::Binding/execute()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\B inding.as:321]

      at mx.binding::Binding/watcherFired()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\bind ing\Binding.as:501]

      at mx.binding::Watcher/notifyListeners()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\b inding\Watcher.as:311]

      at mx.binding::PropertyWatcher/eventHandler()[E:\dev\4.5.1\frameworks\projects\framework\src \mx\binding\PropertyWatcher.as:377]