Flex tooltip on spark datagrid header
Is it possible to set开发者_开发百科 a tooltip just on the header of a spark datagrid. I do not want any tooltips on the data - just the header. I have played with mouse over and this sort of looks like it might work. This seems a bit of a hack to me though.
Can anyone help or give me any tips (pun intended)?
Thanks
you should have to:
- create a custom spark datagrid skin...
- create a headerRenderer skin wich extends the GridItemRenderer and put it into th spark datagrid skin
- add a tooltip to the label "labelDispaly"
it should work...
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import spark.components.Grid;
[Bindable]private var collection:ArrayCollection = new ArrayCollection([
{field01:"field01", content:"your content", field02:"field02"},
{field01:"field01", content:"your content your content your content your content", field02:"field02"},
{field01:"field01", content:"your content your content your content your content", field02:"field02"}
]);
]]>
</fx:Script>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import spark.events.GridEvent;
import spark.components.Image;
[Bindable]
private var myArrivalShips:ArrayCollection = new ArrayCollection([
{arrivalShipsName:"Ship A", ETD:"12 March"},
{arrivalShipsName:"Ship B", ETD:"25 March"}
]);
private function buildToolTip(item:Object,column:GridColumn):String{
var myString:String = "";
if(column.columnIndex==0){
myString=myString+"Arrival Ships";
}
else if(column.columnIndex==1){
myString=myString+"ETD";
}
return myString;
}
]]>
</fx:Script>
<s:BorderContainer x="267" y="11" width="331" height="586">
<s:DataGrid id="arrivalTable" x="10" y="326" width="302" height="205" requestedRowCount="4" dataProvider="{myArrivalShips}" showDataTips="true" dataTipFunction="buildToolTip">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="arrivalShipsName" headerText="Arrival Ships"></s:GridColumn>
<s:GridColumn dataField="ETD" headerText="ETD"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:BorderContainer x="10" y="19" width="302" height="285">
</s:BorderContainer>
</s:BorderContainer>
</s:Application>
精彩评论