meteorWJ's Home—Floating clound

I just want to stay in the peaceful corner, leave away from black, enjoy the sunshine....

用户操作
[即时聊天] [发私信] [加为好友]
meteorWJID:meteorlWJ
84819次访问,排名1186,好友42人,关注者50人。
我的生活是一条船,永远都走在会波动的海面上
meteorlWJ的文章
原创 196 篇
翻译 1 篇
转载 287 篇
评论 202 篇
meteorWJ的公告
最近评论
meteorlWJ:大家都到齐了,真好,呵呵,下次再见面一定要好好吃个饭
Vanessa219:轻松的活着。。。
DL88250:我老了,生锈了。。。。
elevenXL:eleven , vanessa, 88250. 好难得,大家竟都在CSDN上有共同的爱好与默契,大三的生活把我们的友情连在了一起,以前是,现在是,以后也是。开心的,不开心的,都过去了,现在想见一面都不容易了...
确实是这样,希望大家都会好好的..
DL88250:: -)
文章分类
收藏
    相册
    12块世界最贵手表
    12星座戒指
    ME
    meteor
    我的珍藏
    我的另一个地盘...
    My QQ-Zone
    校内网的我....
    深蓝泡泡鱼's Blog
    我的收藏.....
    DL88250's Blog
    eleven's Blog
    owndict
    VCer资源中心
    中华电脑书库-资料下载网
    中国IT动力,最新最全的IT技术教程
    软件测试培训
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 Formatting a Flex DataGrid control using a custom 收藏

    新一篇: Changing the default skins on a Button control in Flex | 旧一篇: 软件工厂简介

    The following example formats a column in a Flex DataGrid and uses a custom item renderer to color the text red in a cell if a price is below $0. If the item is greater than $0, the test is displayed in black. The price column is also formatted using a custom label function, which uses a CurrencyFormatter, and finally, the data grid column uses a custom sort function to properly sort numeric columns.

    Full code after the jump.

     

    View MXML

    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/ -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            layout="vertical"
            verticalAlign="middle"
            backgroundColor="white">
    
        <mx:Script>
            <![CDATA[
                import mx.controls.dataGridClasses.DataGridColumn;
                import mx.utils.ObjectUtil;
    
                private function price_labelFunc(item:Object, column:DataGridColumn):String {
                    return currencyFormatter.format(item.@price);
                }
    
                private function price_sortCompareFunc(itemA:Object, itemB:Object):int {
                    return ObjectUtil.numericCompare(itemA.@price, itemB.@price);
                }
            ]]>
        </mx:Script>
    
        <mx:XML id="itemsXML">
            <items>
                <item name="Item 1" price="1.32" />
                <item name="Item 2" price="-12.23" />
                <item name="Item 3" price="4.96" />
                <item name="Item 4" price="-0.94" />
            </items>
        </mx:XML>
    
        <mx:Style>
            .centered {
                text-align: center;
            }
        </mx:Style>
    
        <mx:CurrencyFormatter id="currencyFormatter"
                precision="2"
                useNegativeSign="false" />
    
        <mx:DataGrid id="dataGrid" dataProvider="{itemsXML.item}">
            <mx:columns>
                <mx:DataGridColumn dataField="@name"
                        headerText="Name:"
                        headerStyleName="centered" />
    
                <mx:DataGridColumn dataField="@price"
                        headerText="Price:"
                        textAlign="right"
                        headerStyleName="centered"
                        labelFunction="price_labelFunc"
                        sortCompareFunction="price_sortCompareFunc"
                        itemRenderer="PriceLabel" />
            </mx:columns>
        </mx:DataGrid>
    
    </mx:Application>
    
    

    PriceLabel.as

    package {
        import mx.controls.Label;
        import mx.controls.listClasses.*;
    
        public class PriceLabel extends Label {
    
            private const POSITIVE_COLOR:uint = 0x000000; // Black
            private const NEGATIVE_COLOR:uint = 0xFF0000; // Red 
    
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                super.updateDisplayList(unscaledWidth, unscaledHeight);
    
                /* Set the font color based on the item price. */
                setStyle("color", (data.@price <= 0) ? NEGATIVE_COLOR : POSITIVE_COLOR);
            }
        }
    }
    

    View source is enabled in the following example.

     

    发表于 @ 2008年08月25日 08:31:00|评论(loading...)|收藏

    新一篇: Changing the default skins on a Button control in Flex | 旧一篇: 软件工厂简介

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © meteorWJ