小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

改变DataGrid组件中排序的“小三角”的样式.

其实就是利用DataGrid的sortArrowSkin属性~
玩FLEX玩的不好,很多时候是因为对组件的属性知道的不充分啊~
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/23/changing-the-default-sort-arrow-skin-on-a-flex-datagrid-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" applicationComplete="init()">
<mx:Style>
    DataGrid {
        sortArrowSkin: Embed("assets/thumb_down.png");
    }
</mx:Style>
<mx:Script>
    
<![CDATA[
        [Embed("assets/thumb_down.png")]
        private var thumbDownIcon:Class;

        private function init():void {
            dataGrid.setStyle("sortArrowSkin", thumbDownIcon);
        }
    
]]>
</mx:Script>

    
<mx:Array id="arr">
        
<mx:Object c1="Item 1A" c2="Item 1B" />
        
<mx:Object c1="Item 2A" c2="Item 2B" />
        
<mx:Object c1="Item 3A" c2="Item 3B" />
        
<mx:Object c1="Item 4A" c2="Item 4B" />
        
<mx:Object c1="Item 5A" c2="Item 5B" />
        
<mx:Object c1="Item 6A" c2="Item 6B" />
        
<mx:Object c1="Item 7A" c2="Item 7B" />
        
<mx:Object c1="Item 8A" c2="Item 8B" />
        
<mx:Object c1="Item 9A" c2="Item 9B" />
    
</mx:Array>

    
<mx:DataGrid id="dataGrid"
            dataProvider
="{arr}"
            sortArrowSkin
="@Embed('assets/thumb_down.png')"
            width
="300"
            rowCount
="8">
        
<mx:columns>
            
<mx:DataGridColumn dataField="c1"
                    headerText
="Column 1:" />
            
<mx:DataGridColumn dataField="c2"
                    headerText
="Column 2:" />
        
</mx:columns>
    
</mx:DataGrid>

</mx:Application>

原文地址:http://blog.flexexamples.com/2008/02/23/changing-the-default-sort-arrow-skin-on-a-flex-datagrid-control/

posted on 2008-03-31 17:30  『小小菜鸟』  阅读(864)  评论(0编辑  收藏  举报