Originally I was trying to do this the easy way as an mxml file.  As I have found many times when building reusable parts a simple mxml file always falls short.  So after figuring out all the action script I was about to set the selected index in the click event.  Just seems like a lot of hoops to jump through.  

 

Thanks

 

Jeff

 

Base class

 

class flex.component.core.DataGridLink extends UIComponent

{

   var link : MovieClip;

   var listOwner : MovieClip; // The reference we receive to the list.

   var getCellIndex : Function; // The function we receive from the list.

   var getDataLabel : Function; // The function we receive from the list.

 

   function DataGridLink() {

   }

 

   function createChildren() : Void {

                        link = createClassObject(Link, "link", 1, {styleName:this,

                         owner:this});

                        link.addEventListener("click",mx.utils.Delegate.create(this,linkClicked));

                        link.setStyle("textDecoration","underline");

                        link.setStyle("color","#000099");

                        size();

   }

  

 

   function setValue(str:String, item:Object, sel:Boolean) : Void {

                        link.label = str;

                        link.width = (str.length * 9);

   }

 

   function getPreferredHeight() : Number {

      return 16;

   }

 

   function getPreferredWidth() : Number {

      return 60;

   }

   function linkClicked( event ) {

                           listOwner.selectedIndex = getCellIndex().itemIndex;

   }

}

 

 

Implementation

<corecomponent:DataGridLink xmlns:corecomponent="flex.component.core.*"

                                                                                    xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:Script>

      <![CDATA[

                        import flex.view.cm.VideoViewHelper;

                        import com.iterationtwo.cairngorm.view.ViewLocator;

                        function linkClicked( event )

                        {

                                    super.linkClicked(event);

                                    var videoViewHelper = ViewLocator.getInstance().getViewHelper( VideoViewHelper.LOOKUP_NAME );

                                    videoViewHelper.openProjectScript();

                        }

      ]]>

   </mx:Script>            

</corecomponent:DataGridLink>

 


From: [email protected] [mailto:[email protected]] On Behalf Of Matt Chotin
Sent: Monday, May 09, 2005 9:58 PM
To: [email protected]
Subject: RE: [flexcoders] Re: DataGrid mouseDown event row selection problem

 

Can you just set selectedItem to be the associated item for the Link?  In setValue you’ll be passed a reference to the item, so just hold onto it and then in the click event of Link you set the DataGrid’s selectedItem to that.

 


From: [email protected] [mailto:[email protected]] On Behalf Of Jeff Krueger
Sent: Monday, May 09, 2005 8:49 PM
To: [email protected]
Subject: RE: [flexcoders] Re: DataGrid mouseDown event row selection problem

 

No I mean that when I click on the link it does everything I want, the only problem is the row does not become selected.  

 

When I hover over the link I get the finger pointer.

 

Jeff

 


From: [email protected] [mailto:[email protected]] On Behalf Of Matt Chotin
Sent: Monday, May 09, 2005 9:36 PM
To: [email protected]
Subject: RE: [flexcoders] Re: DataGrid mouseDown event row selection problem

 

You mean the Link is bringing up an I-beam?  That seems odd to me, can you show some code?

 


From: [email protected] [mailto:[email protected]] On Behalf Of Jeff Krueger
Sent: Monday, May 09, 2005 9:57 AM
To: [email protected]
Subject: RE: [flexcoders] Re: DataGrid mouseDown event row selection problem

 

I am having the same problem, but my cell renderer is not a text control but instead a link.  There is no selectable property on a link, so is there any other way I can get the link to receive the click, but also have it select the row in the grid?  

 

Thanks

 

Jeff

 


From: David Gassner [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 19, 2004 1:35 AM
To: [email protected]
Subject: [flexcoders] Re: DataGrid mouseDown event row selection problem

 


In the cell renderer, set the Text control's 'selectable' property
to false; this will prevent the mouse click from begin captured by
that control, and the grid row will be selectable.

--- In [email protected], "oksteev" <[EMAIL PROTECTED]> wrote:
>
> So I have a DataGrid and one of the cols has a custom CellRenderer
> which is just a mx:Box with an mx:Text inside of it, basically
> mimicking a standard DataGrid non-editable cell.
>
> The problem is when you click on an area of the cell with text in
it
> (cursor becomes I-shaped) the click (mouseDown i think) does not
make
> it to the correct object (the DataGrid, I THINK...) and thus the
row
> does not get selected.  If I click in an area w/o the text (but
still
> in the Box) the DataGrid receives a mouseDown event (verified this)
> and the row is selected.
>
> side note: the box does not receive this mousedown event even tho
the
> mouse is inside the box (i used borders to check). this may be
because
> it is an 'empty' part of the box
>
> So I tried catching the mouseDown event in the box and then
> calculating the appropriate mouse cooridnates relative to the
DataGrid
> (verified they were the same as the event which originates from DG
> when clicking in box but not on text) and did a .dispatchEvent on
the
> datagrid with this new event.  Row doesn't get selected...
>
> Am I missing/forgetting to set some other event property?
>
> note: if I use Label instead of Text row gets selected fine,
because
> label text is non-selectable but I don't wan't to use Labels so
that's
> not solution for me.
>
> Thanks in advance.
>
> * steve

 

 

 



Yahoo! Groups Links

Reply via email to