Flex column numeric value in a tabular format

Source: Internet
Author: User

1. Background of the problem

In general. The ratio shown in the table. The control rate is handled by preserving two decimal places and keeping them up


2. Implementation examples

<?

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 "width=" 100% "height=" 100% "fontSize=" "Font family= "Microsoft Jas Black" ><s:layout><s:basiclayout/></s:layout><fx:script><! [Cdata[import Mx.collections.arraycollection;import mx.events.flexevent;[ bindable]//table Data Binding private var gridarray:arraycollection = new ArrayCollection ([{week: "Monday", Apple: "3676", Rate: "0.7868 "},{week: Tuesday", Apple: "4534", Rate: "0.65454"},{week: "Wednesday", Apple: "6758", Rate: "0.876454"},{week: "Thursday", Apple: "9808" , Rate: "0.34224"},{week: "Friday", Apple: "6567", Rate: "0.9876523"},{week: "Saturday", Apple: "9000", Rate: "0.566777"},{week: " Sunday ", Apple:" 4533 ", Rate:" 0.988787 "}]);/** * Formats the ratios in tables */private function Formatdatagrid (item:object,column:d Atagridcolumn): String{var temp:number = Item.rate;var data:string = Dataformatter.format (temp); return data;}]] ></fx:script><fx:declarations><!--formatted digital--><mx:numberformatter id= "Dataformatter" precision= "2" rounding= "Up"/></fx:d Eclarations><mx:vbox width= "100%" height= "100%" paddingbottom= "ten" paddingleft= "paddingright=" 20 " paddingtop= "horizontalalign=" center "><mx:datagrid id=" DataGrid "width=" 100% "height=" 90% "dataprovider=" { Gridarray} "textalign=" center "><mx:columns><mx:datagridcolumn headertext=" Week "datafield=" Week "/> <mx:datagridcolumn headertext= "Apple" datafield= "apple"/><mx:datagridcolumn headertext= "ratio" dataField= "rate" labelfunction= "Formatdatagrid"/></mx:columns></mx:datagrid></mx:vbox></s:application >


3. Achieve Results

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvew91mjnoywk0nq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "width=" 710 "height=" 378 "border=" 1 ">

Flex column numeric value in a tabular format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.