hi ravi

below is my class

if i use the below class the data getting displayed but drag and drop not
hapenning

public class DropTargetRenderer extends Canvas  implements
IDropInListItemRenderer
       {
           private var _listData:DataGridListData;
        private var textData:Text=new Text();

               public function DropTargetRenderer()
               {
                       super();

this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);

this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);

this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
               }
                public function get listData():BaseListData
    {
        return _listData;
    }
     public function set listData(value:BaseListData):void
    {
        _listData = DataGridListData(value);
    }
    override public function set data(value:Object):void
    {
         this.removeAllChildren()
        super.data=value;
        textData.text=String(data[_listData.dataField]);

               this.addChild(textData);
           }

               public function dragEnterHandler(e:DragEvent):void{
                       var dropTarget:Text = e.currentTarget as Text;


if(e.dragSource.hasFormat('value')){
                               DragManager.acceptDragDrop(dropTarget);
                       }
               }
               public function
dragExitHandler(e:DragEvent):void{
                       var dropTarget:DataGridListData = e.currentTarget as
DataGridListData;
               }

               public function
dragDropHandler(e:DragEvent):void{
                       var value:String =
e.dragSource.dataForFormat('value') as String;
                       (e.currentTarget as Text).text +="\n"+ value
;
               }
       }

when i change the above class by extending text

in the datagrid it is showing as [Object object]

but drag and drop is happening



  public class DropTargetRenderer extends Text  implements
IDropInListItemRenderer
       {
           private var _listData:DataGridListData;
        private var textData:Text=new Text();

               public function DropTargetRenderer()
               {
                       super();

this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);

this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);

this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
               }
              override  public function get listData():BaseListData
    {
        return _listData;
    }
    override public function set listData(value:BaseListData):void
    {
        _listData = DataGridListData(value);
    }
    override public function set data(value:Object):void
    {
        // this.removeAllChildren()
        super.data=value;
        textData.text=String(data[_listData.dataField]);

               this.addChild(textData);
           }

               public function dragEnterHandler(e:DragEvent):void{
                       var dropTarget:Text = e.currentTarget as Text;


if(e.dragSource.hasFormat('value')){
                               DragManager.acceptDragDrop(dropTarget);
                       }
               }
               public function
dragExitHandler(e:DragEvent):void{
                       var dropTarget:DataGridListData = e.currentTarget as
DataGridListData;
               }

               public function
dragDropHandler(e:DragEvent):void{
                       var value:String =
e.dragSource.dataForFormat('value') as String;
                       (e.currentTarget as Text).text +="\n"+ value
;
               }
       }

Any help if you want i can send full code

-- 
Karthik.k
Mobile - +91-9894991640
http://kkarthikresume.blogspot.com/

On Fri, May 29, 2009 at 3:41 PM, Ravi Mishra <[email protected]> wrote:

>
> Hi Karthik,
>
> Where did u put the following function
>
> public function DropTargetRenderer()
>               {
>                       super();
>
> this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);
>
> this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);
>
> this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
>               }
>
>
> make sure u call this function in the constructor of the class you are
> using it.
>
> HTH,
>
> -Ravi
>
>
>
> On May 28, 4:14 pm, Karthik K <[email protected]> wrote:
> > hi Ravi
> >
> > i have one doubt
> >
> > i am already having one itemrenderer when i place the class data of
> > DropTargetRenderer inside my renderer it is having some problem
> >
> > below is the class i am using
> >
> > for all datagrid columns only one itemrenderer
> >
> > First i need to display data and after that drag and drop should work
> >
> > below will display data
> >
> > public class sampleItemRenderer extends Canvas  implements
> > IDropInListItemRenderer
> > {
> >     private var _listData:DataGridListData;
> >     private var textData:Text=new Text();
> >     private var str : String ="";
> >     private var arr : Array ;
> >     private var canvas:Canvas=new Canvas();
> >     private var canvas1:Canvas=new Canvas();
> >     public function sampleItemRenderer()
> >     {
> >         super();
> >     }
> >      public function get listData():BaseListData
> >     {
> >         return _listData;
> >     }
> >      public function set listData(value:BaseListData):void
> >     {
> >         _listData = DataGridListData(value);
> >     }
> >     override public function set data(value:Object):void
> >     {
> >          this.removeAllChildren()
> >         super.data=value;
> >         textData.text=String(data[_listData.dataField]);
> >         textData.height=50;
> >         textData.width=160
> >         arr  = textData.text.split(",");
> >         var box:VBox=new VBox();
> >         for(var i:int=0;i<arr.length;i++)
> >         {
> >             var text:Text = new Text();
> >             text.text = arr[i].toString();
> >              box.addChild(text);
> >                this.addChild(box);
> >            }
> >     }
> >
> > }
> >
> > when i place your data drag and drop not happening
> >
> >  public function DropTargetRenderer()
> >                {
> >                        super();
> >
> > this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);
> >
> > this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);
> >
> > this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
> >                }
> >                public function dragEnterHandler(e:DragEvent):void{
> >                        var dropTarget:Text = e.currentTarget as Text;
> >
> > if(e.dragSource.hasFormat('value')){
> >                                DragManager.acceptDragDrop(dropTarget);
> >                        }
> >                }
> >                public function
> > dragExitHandler(e:DragEvent):void{
> >                        var dropTarget:DataGridListData = e.currentTarget
> as
> > DataGridListData;
> >                }
> >
> >                public function
> > dragDropHandler(e:DragEvent):void{
> >                        var value:String =
> > e.dragSource.dataForFormat('value') as String;
> >                        (e.currentTarget as Text).text += value
> > ;
> >                }
> >
> > it is not displaying
> >
> > any idea
> >
> > please help
> >
> > --
> > Karthik.k
> > Mobile - +91-9894991640http://kkarthikresume.blogspot.com/
> >
> > On Wed, May 27, 2009 at 6:45 PM, Karthik K <[email protected]>
> wrote:
> > > hi Ravi
> >
> > > I did that myself but sorry for not responding you
> >
> > > Thanks Ravi
> >
> > > --
> > > Karthik.k
> > > Mobile - +91-9894991640
> > >http://kkarthikresume.blogspot.com/
> >
> > > On Wed, May 27, 2009 at 6:43 PM, Ravi Mishra <[email protected]
> >wrote:
> >
> > >> Yes u can do that also. At the time of drop, add "/n" into the string.
> > >> i. e.
> >
> > >> private function dragDropHandler(e:DragEvent):void{
> > >>                        var value:String = e.dragSource.dataForFormat
> > >> ('value') as String;
> >
> > >>                         (e.currentTarget as Text).text + "/n" +=
> > >> value;
> > >>                }
> >
> > >> Try that out. I think it will help
> >
> > >> -Ravi
> >
> > >> On May 27, 3:48 pm, Karthik K <[email protected]> wrote:
> > >> > hi Ravi
> >
> > >> > Thanks a lot
> >
> > >> > Great Example
> >
> > >> > i have one doubt
> >
> > >> > can i  place the dropped data next line i.e inside same cell because
> my
> > >> req
> > >> > is of that type
> > >> > i am creating calender application so that each event e.g between
> 8:00
> > >> to
> > >> > 9:00 there will be three events one below the other
> > >> > so when i drag and drop if it is coming in next line will be very
> great
> >
> > >> > --
> > >> > Karthik.k
> > >> > Mobile - +91-9894991640http://kkarthikresume.blogspot.com/
> >
> > >> > On Wed, May 27, 2009 at 1:32 PM, Ravi Mishra <
> [email protected]>
> > >> wrote:
> >
> > >> > > hi karthik,
> >
> > >> > > try this
> >
> > >> > > <!--Main.mxml file-->
> > >> > > <?xml version="1.0" encoding="utf-8"?>
> > >> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > >> > > layout="vertical">
> > >> > > <mx:ArrayCollection id="ac">
> > >> > >    <mx:Object ename="aaa" eno="111" sal="2000"/>
> > >> > >    <mx:Object ename="bbb" eno="222" sal="9000"/>
> > >> > >    <mx:Object ename="ccc" eno="333" sal="43000"/>
> > >> > >    <mx:Object ename="ddd" eno="444" sal="8000"/>
> > >> > >    <mx:Object ename="eee" eno="555" sal="5000"/>
> > >> > > </mx:ArrayCollection>
> >
> > >> > >        <mx:TextInput id="ti" text="Text Comes Here"/>
> > >> > >        <mx:DataGrid id="dg" dataProvider="{ac}">
> > >> > >                <mx:columns>
> > >> > >                        <mx:DataGridColumn dataField="ename"
> > >> > > itemRenderer="com.CustomRenderer" editorDataField="text"/>
> > >> > >                        <mx:DataGridColumn dataField="eno"
> > >> > > itemRenderer="com.DropTargetRenderer" editorDataField="text"/>
> > >> > >                        <mx:DataGridColumn dataField="sal"
> > >> > > itemRenderer="com.DropTargetRenderer" editorDataField="text"/>
> > >> > >                </mx:columns>
> > >> > >        </mx:DataGrid>
> > >> > > </mx:Application>
> >
> > >> > > //CustomRenderer file
> > >> > > package com
> > >> > > {
> > >> > >        import flash.events.MouseEvent;
> >
> > >> > >        import mx.controls.Image;
> > >> > >        import mx.controls.Text;
> > >> > >        import mx.controls.dataGridClasses.DataGridListData;
> > >> > >        import mx.core.DragSource;
> > >> > >        import mx.managers.DragManager;
> >
> > >> > >        public class CustomRenderer extends Text
> > >> > >        {
> > >> > >                public function CustomRenderer()
> > >> > >                {
> > >> > >                        super();
> > >> > >                        this.setStyle("fontWeight","bold");
> > >> > >                        this.setStyle("textAlign","left");
> >
> > >> > >  this.addEventListener(MouseEvent.MOUSE_MOVE,handleDrag);
> > >> > >                }
> >
> > >> > >                override public function set
> data(value:Object):void{
> > >> > >                        super.data = value;
> > >> > >                        this.text = this.data[(listData as
> > >> > > DataGridListData).dataField];
> >
> > >> > >  //this.addEventListener(MouseEvent.CLICK,clickHandler);
> > >> > >                }
> > >> > >                /* private function
> clickHandler(e:MouseEvent):void{
> >
> > >> > >                }
> > >> > >                 */
> >
> > >> > >                private function handleDrag(e:MouseEvent):void{
> > >> > >                        var obj:String = this.text;
> > >> > >                        var dragInitiator:Text = e.currentTarget as
> > >> Text;
> > >> > >                        var dragSource:DragSource = new
> DragSource();
> > >> > >                        dragSource.addData(obj,'value');
> > >> > >                        var dragProxy:Image = new Image();
> > >> > >                        dragProxy.source = "admin2.gif";
> >
> > >> > >  DragManager.doDrag(dragInitiator,dragSource,e,dragProxy);
> > >> > >                }
> > >> > >        }
> > >> > > }
> >
> > >> > > //DropTargetRenderer.as file
> > >> > > package com
> > >> > > {
> > >> > >        import mx.controls.Text;
> > >> > >        import mx.events.DragEvent;
> > >> > >        import mx.managers.DragManager;
> >
> > >> > >        public class DropTargetRenderer extends Text
> > >> > >        {
> > >> > >                public function DropTargetRenderer()
> > >> > >                {
> > >> > >                        super();
> >
> > >> > >  this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);
> >
> > >> > >  this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);
> >
> > >> > >  this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
> > >> > >                }
> >
> > >> > >                private function
> dragEnterHandler(e:DragEvent):void{
> > >> > >                        var dropTarget:Text = e.currentTarget as
> Text;
> >
> > >> > >                        if(e.dragSource.hasFormat('value')){
> > >> > >
>  DragManager.acceptDragDrop(dropTarget);
> > >> > >                        }
> > >> > >                }
> >
> > >> > >                private function dragExitHandler(e:DragEvent):void{
> > >> > >                        var dropTarget:Text = e.currentTarget as
> Text;
> > >> > >                }
> >
> > >> > >                private function dragDropHandler(e:DragEvent):void{
> > >> > >                        var value:String =
> > >> > > e.dragSource.dataForFormat('value') as String;
> >
> > >> > >                        (e.currentTarget as Text).text += value;
> > >> > >                }
> > >> > >        }
> > >> > > }
> >
> > >> > > Put all the above mentioned files in the relevant packages and
> run.
> > >> > > Try to drag a value from first column and drop it to either 2nd or
> 3rd
> > >> > > column.
> >
> > >> > > HTH,
> >
> > >> > > -Ravi
> >
> > >> > > On May 27, 11:44 am, Karthik K <[email protected]> wrote:
> > >> > > > hi Ravi
> >
> > >> > > > when i drag to the cell(where one data already exist) it is not
> > >> standing
> > >> > > in
> > >> > > > the exact cell
> > >> > > > it is moving to cell above or below
> >
> > >> > > > if there is any example
> > >> > > > please help me
> >
> > >> > > > very critical
> >
> > >> > > > --
> > >> > > > Karthik.k
> > >> > > > Mobile - +91-9894991640http://kkarthikresume.blogspot.com/
> >
> > >> > > > On Wed, May 27, 2009 at 12:09 PM, Ravi Mishra <
> > >> [email protected]
> > >> > > >wrote:
> >
> > >> > > > > Yes u can! Just concatenate the dropped data to the previously
> > >> dropped
> > >> > > > > data.
> >
> > >> > > > > -Ravi
> >
> > >> > > > > On May 27, 11:34 am, Karthik K <[email protected]>
> wrote:
> > >> > > > > > hi guys
> >
> > >> > > > > > i have one doubt
> >
> > >> > > > > > can i drag and drop data in same cell twice means
> > >> > > > > > i am dragging data to
> >
> > ...
> >
> > read more ยป
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to