2 Replies Latest reply on Jul 22, 2008 11:05 AM by wkolcz

    Formatting text for a list

    wkolcz Level 1
      I call to a CFC that return a list of names (firstName, lastName) and a uniqname that is set to populate to a list via the dataprovider. It comes up as undefined, undefined.

      I thought I would use the labelFunction to return a formatted name (lastName, firstName). Problem is I don't know how to pass the data to the function that then populates the list. I want the selected value to be the uniqname.

      Here is my list:
      <mx:List id="frmProjectTeam" allowMultipleSelection="true" height="110" width="100%" labelFunction="formatNames"> </mx:List>

      Here is my formatName function, the remoteobject, and the resulthandler:
      public function formatNames(person:Object):String {
      return person.lastname + ', ' + person.firstname;
      }

      private function returnHandler(e:ResultEvent):void {
      frmProjectTeam.dataProvider = e.result;
      }

      <mx:RemoteObject id="teamGateway" destination="ColdFusion" source="edu.umich.peopleGateway" fault="Alert.show(event.fault.message), 'Error'">
      <mx:method name="list" makeObjectsBindable="true" result="returnHandler(event)"/>
      </mx:RemoteObject>

      How can I pass the data from the provider function into the list and then get the uniqname as the value of the selected item? thanks!
        • 1. Re: Formatting text for a list
          Level 7

          "projectproofing" <webforumsuser@macromedia.com> wrote in message
          news:g654fa$j6q$1@forums.macromedia.com...
          >I call to a CFC that return a list of names (firstName, lastName) and a
          > uniqname that is set to populate to a list via the dataprovider. It comes
          > up as
          > undefined, undefined.
          >
          > I thought I would use the labelFunction to return a formatted name
          > (lastName,
          > firstName). Problem is I don't know how to pass the data to the function
          > that
          > then populates the list. I want the selected value to be the uniqname.
          >
          > Here is my list:
          > <mx:List id="frmProjectTeam" allowMultipleSelection="true" height="110"
          > width="100%" labelFunction="formatNames"> </mx:List>
          >
          > Here is my formatName function, the remoteobject, and the resulthandler:
          > public function formatNames(person:Object):String {
          > return person.lastname + ', ' + person.firstname;
          > }
          >
          > private function returnHandler(e:ResultEvent):void {
          > frmProjectTeam.dataProvider = e.result;
          > }
          >
          > <mx:RemoteObject id="teamGateway" destination="ColdFusion"
          > source="edu.umich.peopleGateway" fault="Alert.show(event.fault.message),
          > 'Error'">
          > <mx:method name="list" makeObjectsBindable="true"
          > result="returnHandler(event)"/>
          > </mx:RemoteObject>

          The code that you have looks like it should just work. What problems/errors
          are you having?


          • 2. Re: Formatting text for a list
            wkolcz Level 1
            It comes up as undefined, undefined. I am not passing in the data from the CFC into the formatting function.

            public function formatNames(person:Object):String {
            return person.lastname + ', ' + person.firstname;
            }

            I am guessing it is the Object I created. Don't know how to connect the two (formatName function and returnHandler.