Using a label function with one-column List-based components : List Label « Components « Flex






Using a label function with one-column List-based components

Using a label function with one-column List-based components
           

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundColor="white">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        import mx.events.ListEvent;
        import mx.controls.Alert;
        public var myAC:ArrayCollection = new ArrayCollection([
            {name:"A", email:"a@domain.com"},
            {name:"B", email:"b@domain.com"}]);

        public function handleClick(evt:ListEvent):void
        {
            Alert.show(evt.rowIndex + " / col:" + evt.columnIndex + "." + "for " + evt.currentTarget.selectedItem.name);
        }
        public function fullName(rowItem:Object):String
        {
            return rowItem.firstName + ' ' + rowItem.lastName;
        }
      
    </mx:Script>
    <mx:List dataProvider="{myAC}" labelFunction="fullName" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using labelField to tell List which column to presentUsing labelField to tell List which column to present
2.Combine label and data for List itemCombine label and data for List item
3.Using a label function to support a single-column List componentUsing a label function to support a single-column List component
4.Get selected item label from a listGet selected item label from a list
5.Drag and drop label value to a ListDrag and drop label value to a List
6.Format List with labelFunction propertyFormat List with labelFunction property
7.Set label field for data source of List controlSet label field for data source of List control
8.Using a function to combine the values of the label and data fields for each item for display in the List controlUsing a function to combine the values of the label and data fields for each item for display in the List control
9.Use a label function to concatenate the firstName and lastName fields of each data item for display by the controlUse a label function to concatenate the firstName and lastName fields of each data item for display by the control