Skip navigation
Currently Being Moderated

ToolTip for AdvancedDataGrid

Nov 24, 2010 10:35 PM

Hello,

 

I would I to ask how to create a tooltip in AdvancedDataGrid.

My MXML component is a VBox based component.

 

This is the code for my custome ToolTip using Panel:

 

<fx:Script>

 

   <![CDATA[

 

    import mx.controls.Alert;

    import mx.events.FlexEvent;      

 

    [Bindable]

 

    public var _dataId:String;

    protected function dataGrid_creationCompleteHandler(event:FlexEvent):void

    {

        var dataid:String;

        dataid = _dataId;

        getSpecificUserDataCResult.token = twitterSentimentManager.getSpecificUserDataC(dataid);

    }

 

 

    protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void

    {

        var dataid:String;

        dataid = _dataId;

        getSpecificUserDataUResult.token = twitterSentimentManager.getSpecificUserDataU(dataid);

    }  

 

    ]]>

</fx:Script>

 

 

 

 

This is the code for AdvancedDataGrid:

 

<fx:Script>

 

    <![CDATA[

        import mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer;

        import mx.events.FlexEvent;

        import mx.events.ListEvent;

        import mx.events.ToolTipEvent;

        import spark.components.IItemRenderer;     

 

        private function createCustomToolTip(event:ToolTipEvent):void {

                var toolTip:CustomToolTip = new CustomToolTip();

                toolTip._dataId = event.target.data;

                event.toolTip=toolTip;

            }

 

        private function createCustomToolTip(event:ToolTipEvent):void {

            var toolTip:CustomToolTip = new CustomToolTip();

            var dataid:String = AdvancedDataGridItemRenderer(event.itemRenderer).data.userID;

            toolTip._dataId = dataid;          

            event.toolTip=toolTip;

        }

 

        ]]>

 

</fx:Script>

 

<mx:AdvancedDataGrid x="48" y="50" id="myADG" designViewDataType="tree" data="myADG.currentItem" toolTipCreate="createCustomToolTip(event)" selectedIndex="0" creationComplete="myADG_creationCompleteHandler(event)" dataProvider="{getSpecificCountryCollection}">

 

    <mx:columns>

        <mx:AdvancedDataGridColumn headerText="sentiment" dataField="sentiment"/>      

        <mx:AdvancedDataGridColumn headerText="userID" dataField="userID"/>

        <mx:AdvancedDataGridColumn headerText="dateTime" dataField="dateTime"/>

    </mx:columns>

 

</mx:AdvancedDataGrid>

</s:TitleWindow>

 

It didnt show any error, but nothing happen when mouseover.

I dont know which part is wrong?

 

Thank You!

 
Replies
  • Currently Being Moderated
    Jul 6, 2012 6:02 AM   in reply to YuHsin4221123

    Hi,

     

    I see that this question is unanswerd for a while, and I came across it when I encountered the same problem.

    If you want to acheive the tootip for each CELL in the datagrid then you can use the ItemOver listener

     

    setup the listener:

     

    dg.addEventListener(ListEvent.ITEM_ROLL_OVER , itemOver);

     

    define itemOver:

     

    public function itemOver(event:ListEvent):void

                {

                    var toolTipText:String                = (AdvancedDataGridItemRenderer)(event.itemRenderer).text; //only if you want to show the text in the cell itself as the tooltip

                    (AdvancedDataGridItemRenderer)(event.itemRenderer).toolTip    = toolTipText;

                }

     

    and thats all you have to do.

     

    Regards

    Faizal

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points