Hi,

Having a problem with using an itemRenderer in datagrid column, the 
custom column appears correctly but whenever I dynamically change the 
dataProvider I get a repeat of the custom column and as I'm 
potentially using a dataProvider with a different schema to the 
initially loaded schema I then get a mixture of the old schema and 
current schema fields. It all appears to work correctly though if I 
don't create the custom column.

See code below for creating custom column which is created when I get 
the data result(onResult) and also the code for the itemRenderer 
(ButtonAddToPlaylist).


Thanks,

Mike
 

private function onResult(event:ResultEvent):void
        {

        // Get the result
        this.dgEventListings.dataProvider = event.result;
                                
                // Add the 'Add to playlist' column
                var dgc:DataGridColumn = new DataGridColumn();
                dgc.headerText = "";
                dgc.width = 26;
                dgc.itemRenderer = new ButtonAddToPlaylist();
                var cols:Array = this.dgEventListings.columns;
                cols.push(dgc);
                this.dgEventListings.columns = cols;
                this.dgEventListings.validateNow();
                
                this.dgEventListings.addEventListener
(AddPlaylistClipEvent.ADD_TO_PLAYLIST, AddPlaylistClip);
                
                // Set the title
                var myParent:SuperPanel = SuperPanel(this.parent);
                myParent.title = StringUtil.substitute("{0} - Events 
Listing",cboSessions.selectedItem.label);
                                
}


<---- ButtonAddToPlaylist.mxml --->
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
         width="16" height="16" 
         horizontalAlign="center" verticalAlign="middle" 
        implements="mx.controls.listClasses.IDropInListItemRenderer, 
mx.core.IFactory">
        
        <mx:Metadata>
                [Event(name="AddPlaylistClip")]
    </mx:Metadata>
        
        <mx:Script>
                <![CDATA[
                import mx.controls.dataGridClasses.DataGridListData;
                import mx.controls.listClasses.BaseListData;
                import mx.events.FlexEvent;
                
                private var _data:Object;
                private var _listData : BaseListData;           
                
                public function newInstance():*
                {
                   return new ButtonAddToPlaylist();
                }
                
        override public function set data(value:Object):void
        {
            _data = value;
            invalidateProperties();
            dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
        }

        override public function get data():Object 
        {
            return _data;
        }
        
                public function get listData() : BaseListData
                {
                        return _listData;            
                }
                
                public function set listData( value : 
BaseListData ) : void
                {
                        _listData = value;
                }
                
                override protected function commitProperties():void
                {
                        super.commitProperties();
                }
                
                override protected function updateDisplayList
(unscaledWidth:Number, unscaledHeight:Number):void
                {
                        super.updateDisplayList
(unscaledWidth,unscaledHeight);
                }
                
                private function AddClipToPlaylist():void
                {
                        dispatchEvent(new AddPlaylistClipEvent(data));
                }
                
                ]]>
        </mx:Script>
        <mx:Image source="@Embed('images/add.png')" 
                buttonMode="true" toolTip="Add this clip to the 
current Playlist"  
                height="16" width="16" 



Reply via email to