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?
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
North America
Europe, Middle East and Africa
Asia Pacific