dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Help accesing the DataGrid from inside the Renderer

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    5

    Help accesing the DataGrid from inside the Renderer

    Hello,
    I have created an renderer to modify the content of one of the columns of the DataGrid.
    Code:
    package {
        import fl.containers.UILoader;
        import fl.controls.listClasses.ICellRenderer;
        import fl.controls.listClasses.ListData;
        import fl.core.InvalidationType;
        import fl.data.DataProvider;
        import flash.events.Event;
    	import flash.display.*;
    	import flash.events.*;
    	import  fl.controls.listClasses.*;
    
        public class LoaderCellRenderer extends CellRenderer implements ICellRenderer {
      
    		var but:button = new button();
    //		protected var _data:Object;
    //        protected var _listData:ListData;
    //        protected var _selected:Boolean;
    
            public function LoaderCellRenderer():void {
    			trace("LoaderCellRenderer "+_listData)
                super();
    			this.mouseChildren = true
    			this.addChild(but )
    			but.gotoAndStop(1);
    			
    			textField.text = "";
    			//this
    			but.addEventListener(MouseEvent.CLICK, buttonClicked);
            }
    		function buttonClicked(evt:Event):void
    		{
    			trace(evt.target.parent.name);
    		}
    		
    		override protected function drawLayout():void {
    			//trace("LoaderCellRenderer "+textField.text)
    			textField.text = "";
    			//textField.width = this.width;
    			//textField.htmlText = textField.text;
    			super.drawLayout();
    		}
            
            
            
        }
    }
    but how can i access the parent DataGrid or anything outside of this class ?
    In Java it can be done, but how can i pass any value to this class.

    My use case is that i click on a delete button and the row is deleted, impossible to do if i cannot access the parent DataGrid and call methods to work with it.

    Thanks

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    I am sorry but this link does not help a bit. It shows how to implement a CellRenderer but it does not show how to call methods on the DataGrid.
    In java you have function and references that can be called from inside the renderer or editor on the parent data structure.

    I need some way to delete a row. Click on a cell and delete that row, and that cell needs to be custom: button or image.

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    That is not true. It shows you how to inactivate rows by changing the cellrenderer. If you want to remove a row use removeItem(Object) or removeItemAt(index). The object is the selectedItem and the index is the selectedIndex. You don't need to change the cellrenderer for that.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    I want to thank you for the help so far, even if we do not find a soldi solution i can try to use a singleton class to acces the data.

    I do not want to change the CellRenderer. I simply want to call methods from inside the CellRenderer, that point to the DataGrid class or any top class.

    Example:
    http://www.battleofgods.com/example.zip

    In the fla you create the DataGrid and set a cell Renderer. The cell renderer creates a movieclip( that was the only way to have a custom CellRenderer to hold any kind of content ). Click on the red box and there that box should delete the row in the datagrid in the buttonClicked method.
    Can i do this ???
    Last edited by mironcaius; 07-04-2009 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center