3 Replies Latest reply on Nov 20, 2010 7:22 AM by shredderPi

    Multiple fields from array in one colum


      hi there,


      have started working in Flex 4 and quite enjoying it, I'm a designer with years of background in HTML-CSS and decided to shift to Flex.


      While testing on a DataGrid with an ArrayCollection as a data provider, I have a firstName and LastName item in my array, is it possible to display it as one column in my DataGrid, what I did to display just both item from the array is


      <mx:DataGridColumn headerText="Name" dataField="firstName" />

      <mx:DataGridColumn headerText="Name" dataField="lastName" />


      my Array is defined in the Script block..


      would appreciate any help from you guys!

        • 1. Re: Multiple fields from array in one colum
          Peter deHaan Level 4

          Create a custom label function which returns a concatenated firstName and lastName:


          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">




                      protected function displayFullName(item:Object, col:DataGridColumn):String {

                          return item.firstName + " " + item.lastName;







                      <mx:DataGridColumn dataField="firstName" />

                      <mx:DataGridColumn dataField="lastName" />

                      <mx:DataGridColumn labelFunction="displayFullName" headerText="full name" />




                          <mx:Object firstName="Xander" lastName="Crews" />

                          <mx:Object firstName="Wendell" lastName="Stamps" />

                          <mx:Object firstName="Grace" lastName="Ryan" />

                          <mx:Object firstName="Arthur" lastName="Watley" />







          • 2. Re: Multiple fields from array in one colum
            Flex harUI Adobe Employee

            Use a labelFunction

            1 person found this helpful
            • 3. Re: Multiple fields from array in one colum
              shredderPi Level 1

              wow, thanks very much that was quick, I was reading a book while working through some samples and already came accross labelFunction,

              understood it clearly from your sample..

              thanks big!