spark datagrid标头上的Flex工具提示

时间:2011-09-21 09:14:22

标签: flex datagrid tooltip flex4 flex-spark

是否可以在spark数据网格的标题上设置工具提示。我不希望数据上有任何工具提示 - 只是标题。我玩过鼠标,这种看起来可能会起作用。这对我来说似乎有些黑客。

任何人都可以帮助或给我任何提示(双关语)吗?

由于

2 个答案:

答案 0 :(得分:1)

你应该:

  1. 创建自定义spark datagrid skin ...
  2. 创建一个headerRenderer皮肤,扩展GridItemRenderer并将其放入spark datagrid皮肤
  3. 将工具提示添加到标签“labelDispaly”
  4. 它应该有用......

答案 1 :(得分:1)

<?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>