I'd like to bump this :) (holidays'n'all)

Check out the example here:

http://www.mindinteraction.com/bin/TestDataGrid2.html (Note Flex2 app)

>Drag an item to generate an exception.<

Basically it's a drag enabled datagrid using drop-in cellrenderer. I'm unsure if the exception
is my fault or a bug. The docs on drop-in cell renderers is not that exhaustive.

Thanks in advance

Cheers

 -michael





Here's the raw code:

***APP ***********************************************************
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">


    <mx:Script>
        <![CDATA[
        import mx.controls.DataGrid;
        import mx.controls.gridclasses.DataGridColumn;
       
        //a test dataset
        public var initDG:Array = [
                { Artist: 'xxx', Price: true, Album: 'x123'},
                { Artist: 'yyy', Price: false, Album: 'y123'} ];
           

        //testing label function
        private function myLabelFunction(rowData:Object, col:DataGridColumn):String
        {
            return (String(rowData.Artist)+"[added info]");
        }

        ]]>
    </mx:Script>
   
    <mx:Panel title="Grid Panel" width="100%" height="100%">
        <mx:DataGrid dataProvider="{initDG}" editable="false" height="100%" width="100%" dragEnabled="true">
        <mx:columns>
            <mx:Array>

                <!-- applying a label function -->
                <mx:DataGridColumn
                    labelFunction="myLabelFunction"
                    columnName="Artist"
                    headerText="Artist" />

                <!--embedding a custom cellrenderer -->
                <mx:DataGridColumn
                    cellRenderer="Cellrender"
                    columnName="Price"
                    headerText="Price" />

                <!-- embedding a control -->
                <mx:DataGridColumn    cellRenderer=" mx.controls.CheckBox" isCellEditor="false" editable="false"
                                    columnName="Album"
                                    headerText="Album" />
            </mx:Array>
        </mx:columns>
        </mx:DataGrid>
    </mx:Panel>
   
</mx:Application>


***Drop-in Cellrenderer ***********************************************************
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.macromedia.com/2005/mxml " xmlns="*" horizontalAlign="center">

<mx:Script>
    <![CDATA[
   
        // Override the setter method.
        override public function set dataObject(value:Object):Void             {        
            if(value != null)
            {
                // Use super to set the value in the base class.
                super.dataObject = value;
                checkImg.visible = value.Price;
            }   
        }   
    ]]>
</mx:Script>

<mx:Image id="checkImg" source="@Embed(source='checkmark.gif')" />

</mx:VBox>













On 12/21/05, Michael Hansen <[EMAIL PROTECTED]> wrote:
Hi!

I've implemented a grid using a drop-in cellrenderer as detailed in (my code is almost identical):

http://livedocs.macromedia.com/labs/1/flex/wwhelp/wwhimpl/js/html/wwhelp.htm?href=""

I also have drag enabled on the grid.

The cellrenderer works fine. However, after I implementing the custom renderer, I get a null reference exception when dragging an item in the grid.

_Looks_ like the drag proxy is not fully cloning the original item (custom renderer ref. is null), which throws an exception when called.

Am I doing something wrong or is this a bug? Anyone else had luck in this kind of implementation?


Best wishes for the holidays!

-michael






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to