Your problem is in the data override you need to let the itemrenderer
retrieve the data, so in this override you require a super.data = oItem; 

  

I have not tested, and this is just by looking at the function.

 

jason



  -----Message d'origine-----
  De : Robb Cundick [mailto:[EMAIL PROTECTED] la part de Robb
Cundick
  Envoyé : mardi 30 janvier 2007 07:00
  À : [email protected]
  Objet : ItemRenderer Problem


  Hello, I'm a Flex newbie in need of some help.

  I'm grabbing an array of data from a Web service and displaying it in a
List component. On the Flex side I store the data in an ArrayCollection, the
name of which I set as the Data Provider for my list. I have a field called
"Display" which I set as the List's labelField. 

  Everything works fine, but then I wanted to get a little fancier and vary
the color of each line based on another field called "MemberStatus." To do
that I wrote an ItemRenderer component which contains a label that I use to
vary the text display.

  In the itemRenderer I override the "set data" function, expecting that I
can then use the supplied Object parameter to reference both the "Display"
field to set as the text of the label, and the "MemberStatus" field to
determine the text color I want for the label. Unfortunately, things don't
work as I think they should. If I override "set data" as follows:

  override public function set data(oItem:Object):void
  {
  displayItem.text = oItem.Display;
  (Followed by additional code using oItem.MemberStatus to determine the
color)
  }

  I get the following error:

  ReferenceError: Error #1069: Property Display not found on String and
there is no default value.
  at memberListRenderer/set data()
  at
mx.controls::List/http://www.adobe.com/2006/flex/mx/internal::setupRendererF
romData()
  at mx.controls::List/measureWidthOfItems()
  at mx.controls::List/mx.controls:List::commitProperties()
  at mx.core::UIComponent/validateProperties()
  at mx.managers::LayoutManager/::validateProperties()
  at mx.managers::LayoutManager/::doPhasedInstantiation()
  at Function/http://adobe.com/AS3/2006/builtin::apply()
  at mx.core::UIComponent/::callLaterDispatcher2()
  at mx.core::UIComponent/::callLaterDispatcher()

  Here's a sample of the output of the web service:

  <?xml version="1.0" encoding="utf-8" ?> 
  <ArrayOfMemberSearchList
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns="http://tempuri.org/";>
  <MemberSearchList>
  <ID>414</ID> 
  <Display>Doe, Jane</Display> 
  <MemberStatus>O</MemberStatus> 
  </MemberSearchList>
  <MemberSearchList>
  <ID>109</ID> 
  <Display>Smith, John</Display> 
  <MemberStatus>C</MemberStatus> 
  </MemberSearchList>
  </ArrayOfMemberSearchList>

  If I just insert the above data exactly "as is" in a test program as type
mx:Model I have no problem; the oItem.Display and oItem.MemberStatus fields
are "legal" and yield the results I want. But when I use the web service I
get the error. 

  I can set the label in the itemRenderer to have a data provider of
{data.Display} and it works using the web service. But that doesn't do me
any good because I have no way to access the MemberStatus field and alter
the color. Obviously the problem has something to do with the oItem field in
"set data" not being what I think it is. Does anyone know what I'm doing
wrong?

  TIA,
  Robb



   

<<attachment: winmail.dat>>

Reply via email to