• flex学习笔记 使用函数,显示实时更新的标签


    <?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">
      <s:layout>
          <s:VerticalLayout/>
      </s:layout>
        <fx:Script>
            <![CDATA[
                private function concatenateName(item:Object):String
                {
                 return item.firstName + " "+item.lastName;
                }
                    
            ]]>
        </fx:Script>
        
        <s:ButtonBar id="buttonBar" labelFunction="concatenateName">
            <mx:ArrayCollection>
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
                <fx:Object firstName ="张" lastName="士鑫" email="zhangshixin@xiangm" phone="188156545103" />
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
                <fx:Object firstName ="张" lastName="士鑫" email="zhangshixin@xiangm" phone="188156545103" />
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
            </mx:ArrayCollection>
        </s:ButtonBar>
    </s:Application>
    View Code

    2使用多列标签函数

    <?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">
      <s:layout>
          <s:VerticalLayout/>
      </s:layout>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.dataGridClasses.DataGridColumn;
                [Bindable]
                public var myAC:ArrayCollection = new ArrayCollection([
                    {name:"马楠", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"白小羽", username:"baixiaoyu",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马a", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马b", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马c", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"}
                ]);
                
                public function formatDate(row:Object, col:DataGridColumn):String
                {
                  var retVal:String ="";
                  if(col.dataField =="dtJoined") retVal = dFmt.format(row.dtJoined);
                  else if (col.dataField =="dtLogin")
                       retVal = dFmt.format(row.dtLogin);
                  return retVal;
                }
                
            ]]>
        </fx:Script>
        <fx:Declarations>
            <mx:DateFormatter id="dFmt" formatString="MM/DD/YY"/>
        </fx:Declarations>
          <mx:DataGrid id="dg" width="500" height="100" dataProvider="{myAC}">
              <mx:columns>
                  <mx:DataGridColumn dataField="name" headerText="Name"/>
                  <mx:DataGridColumn dataField="username" headerText="Username"/>
                  <mx:DataGridColumn dataField="dtJoined" headerText="Joined" labelFunction="formatDate"/>
                  <mx:DataGridColumn dataField="dtLogin" headerText="Last login" labelFunction="formatDate"/>
              </mx:columns>
          </mx:DataGrid>
        
    </s:Application>
    View Code

  • 相关阅读:
    移动端页面开发
    全屏滚动-jQuery插件实现
    面向对象技术
    JS堆栈与拷贝
    util 学习
    node.js 中的全局对象
    在webstrorm中配置好es6 babel【更新:在webstorm中配置.vue和.vue文件中支持es6】
    与后台进行连接,mysql模块 第六篇
    在node.js中使用ejs的demo 第五篇
    项目中经常用到的reset.css文件
  • 原文地址:https://www.cnblogs.com/zhugexiaobei/p/3223132.html
Copyright © 2020-2023  润新知