How can I know when a Button in a Flex DataGrid itemRenderer is clicked?

后端 未结 2 454
陌清茗
陌清茗 2021-01-14 00:37

I have a DataGrid component that displays a few columns of data. It has one additional column that displays a Button that allows the user to take an action with regard to th

2条回答
  •  佛祖请我去吃肉
    2021-01-14 01:11

    Thanks Joel. Here's the final solution I came up with after reading that article (which I've read before). I want to add the item whose Button was clicked to an Array which is a property of another item, so I pass the "other item" into the DataGrid Component as a property, and perform actions against it in the function call from the itemRenderer:

    /* CustomDataGrid.mxml */
    
        
            
        
    
        
            
    
            
    
            
    
            
        
    
    
    /* ActionButtonItemRenderer.as */
    package
    {
        import flash.events.MouseEvent;
    
        import mx.controls.Button;
    
        public class ActionButtonItemRenderer extends Button
        {
            public function ActionButtonItemRenderer()
            {
                super();
    
                label = "Take Action";
            }
    
            override protected function clickHandler(event:MouseEvent):void
            {
                super.clickHandler(event);
    
                var owner:CustomDataGrid = listData.owner as CustomDataGrid;
    
                owner.takeAction(data);
            }
        }
    }
    

提交回复
热议问题