DataGrid formatting

Hello,
I want to use a DataGrid in my application, but with
different formatting depending on each cell (editable or not, text
color, etc.). The app displays a kind of procedure in a grid. Some
cells of the grid are empty and need to be NOT editable, the other
need to be aditable as they are linked to a dataProvider.
Having gone through the flash help, I have the feeling that
you can only set one format for the entire dataGrid. Is that true
or is there a way to get around this? One possibility would be to
have as many dataGrid as there are cells but I wonder if that would
not be too heavy in terms of coding and computer resource to
generate all this.
If you have any advice/solution/example, I would be very
happy to hear them.
Thanks very much in advance
Pierrot

I may have stumbled on to a way to do this inline. Here is
the code excerpt for my DataGridColumn:
<mx:DataGridColumn dataField="posted" headerText="Posted"
width="50">
<mx:itemRenderer>
<mx:Component>
<mx:Text
text="{(data.posted.getMonth()+1)+'/'+(data.posted.getDate())+'/'+data.posted.getFullYear ()}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
Is there a better way? This may not be the most efficient
means available.
Thanks Again,
M. McConnell

Similar Messages

  • DataGrid: Modify Foreground Cell Color A Based on Content Of Cell B - Is it possible?

    Hi there!
    In this forum we can found two nice thread about datagrid format:
    Modifying background color of datagrid based on data in grid
    Change the RowBackground Color of Datagrid
    You can also find a great example here:
    LightSwitch control colors of DataGrid rows and other UI elements
    All the examples are about Format Cell A based on its content. A need an example where Cell A are formated based on Cell B content.
    Is it possible do it?
    Best regards,
    Ciro

    Hi!
    Have you any success in implementing row/cell coloring?
    Maybe I'll sound little pessimistic, but I just lost 3 days getting something similar to work.. LS is just not up to task.. Now I'm not surprised that it went on the road it went (abandoned).. While the idea is great, everything else is just -> meh..
    (and i'm here all the way from beta 1)..
    I have simple "is_active" computed property (but I feel it's the same with properties from related tables) and need to color rows accordingly: green - active, red - inactive.. It works inconsistently.. If you have some complex screen you need to
    find hook points where you could inject methods to tell datagrid to refresh layout (like "datagrid.OnApplyTemplate"), or just "collection.refresh()".. On every screen I used it there is some "catch".. I've
    tried almost everything I could find on net, Dave's example(s), Otis example, some already aged similar SL posts..  tried to connect tables in various combination
    like 0..1 -> 1.. I have even converted my tables logic to RIA services where main table does not have computed properties but whole table is returned with "real" properties from RIA service (so "is_active" is computed before arriving
    to client).. Still same stupidities, inconsistency, "loading_row" not being fired, not to mention troubles in plumbing all together between RIA tables and "real" tables...
    Something so "simple" shouldn't be so complicated to achieve.. If anyone have (kind of) solution I'd like to hear/read it cause right now this "LS thing" have big chance to fly trough my window together with my pc..
    Kivito
    Nobody expects the Spanish Inquisition! (M.P.F.C.)

  • Cfgrid (html) cfwindow and form binding

    Hi All,
    I have a page with 2 cfgrids (html). Select a value in the
    first grid populates the 2nd with appropriate records
    All works as expected.
    I also have a cell renderer on one column that opens a
    cfwindow.
    The cfwindow contains a textarea field (html), it's to big to
    display in the grid.
    All works great except for the initial value of the cfwindow
    form
    In the form I have a hidden field (id) andf the textarea
    field. I have a bind attribute on both of these to get the value.
    Can anyone tell me why the initial value does not work ??
    Ken
    What happened to the "Attach Code" Button ???
    "grid page"
    <cflayout type="vbox" align="center"
    style="height:100%;">
    <cflayoutarea overflow="scroll">
    <cflayout type="vbox" align="center"
    style="height:92%;">
    <cflayoutarea>
    <cfinclude template="inc/nav.htm">
    </cflayoutarea>
    <cflayoutarea>
    <cflayout type="hbox" align="center" padding="5">
    <cflayoutarea align="center" style="width:25%;">
    <cfinclude template="jmoGrid.cfm">
    </cflayoutarea>
    <cflayoutarea align="center" style="width:75%;">
    <cfinclude template="cbGrid.cfm">
    </cflayoutarea>
    </cflayout>
    </cflayoutarea>
    </cflayout>
    </cflayoutarea>
    <cflayoutarea>
    <cf_siteFooter>
    </cflayoutarea>
    </cflayout>
    "grid 1"
    <cfgrid
    name="gridJMO"
    format="html"
    striperows="yes"
    bind="CfC:#Request.comsPath#.jmo.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn} ,{cfgridsortdirection},getSearchString())"
    selectMode="row"
    pageSize="14">
    <cfgridcolumn name="Employee_No" header="Emp No"
    width="80">
    <cfgridcolumn name="JMO_Name" header="Name"
    width="150">
    <cfgridcolumn name="id" header="" display="no">
    </cfgrid>
    "grid 2"
    <cfgrid name="dataGrid"
    format="html"
    striperows="yes"
    onchange="CfC:#Request.comsPath#.cbData.saveCB({cfgridaction},{cfgridrow},{cfgridchanged} )"
    bind="CfC:#Request.comsPath#.cbData.getCB({cfgridpage},{cfgridpagesize},{cfgridsortcolumn },{cfgridsortdirection},{gridJMO.ID})"
    selectmode="edit"
    delete="no"
    width="98%"
    pageSize="12">
    <cfgridcolumn name="Approved"
    header="<center>Approve</center>" width="55">
    <cfgridcolumn name="Call_Date"
    header="<center>Date</center>" width="70">
    <cfgridcolumn name="TimeIn" header="<center>Time
    In</center>" width="55">
    <cfgridcolumn name="TimeOut" header="<center>Time
    Out</center>" width="55">
    <cfgridcolumn name="Pt_MRN"
    header="<center>MRN</center>" width="65">
    <cfgridcolumn name="Caller"
    header="<center>Caller</center>" width="185">
    <cfgridcolumn name="Approver"
    header="<center>Approver</center>" width="145">
    <cfgridcolumn name="Details"
    header="<center>Reason</center>" width="55">
    <cfgridcolumn name="OverTime"
    header="<center>OT</center>" width="55">
    <cfgridcolumn name="Reason" header="" display="no">
    <cfgridcolumn name="id" header="" display="no">
    </cfgrid>
    "window form"
    <cfform name="frmUpdate">
    <cfinput type="text" name="ID" bind="{dataGrid.id}">
    <cflayout type="vbox">
    <cflayoutarea>
    <cftextarea name="fld_Message_Detail"
    bind="{dataGrid.Reason}" rows="12" style="width:90%;"/>
    </cflayoutarea>
    <cflayoutarea align="right" style="margin-left:10px;
    width:90%">
    <cfinput type="button" name="bnt_cancel" value="Cancel"
    onClick="hideRecWin('winDetails');">
    <cfinput type="button" name="bnt_submit" value="Save
    Change" onClick="updateReason();">
    </cflayoutarea>
    </cflayout>
    </cfform>

    I found that is style sheet problem , here is my workaround
    solution:
    1.) use text editor open the css file
    (...\CFIDE\scripts\ajax\resources\ext\css\ext-all.css )
    2.) find '.x-grid-dirty-cell' in the file
    3.) copy & paste my style
    /*------------------- >8 -----------------*/
    /* Start of Grid dirty cell problem - Gordon Fixed
    .x-grid-dirty-cell {
    background: transparent
    url(../images/default/grid/dirty.gif) no-repeat 0 0;
    .x-grid-dirty-cell {
    background: transparent
    url(../images/default/grid/dirty.gif) no-repeat 0 0;
    background-color:cornflowerblue;
    .x-grid-row-alt .x-grid-dirty-cell{
    background-color:cornflowerblue;
    /* End of Grid dirty cell problem
    /*------------------- >8 -----------------*/

  • Formatting a column in a datagrid

    If I want to format some data in a column of a datagrid is
    there a preferred way of doing that? I have used both an
    itemRenderer and a labelFunction
    Is there a preference to one or the other?

    lableFunction can be used when the tweaking required is very
    trivial and you want to modify some text getting displayed.
    (custom) itemRenderers can be used when we want to display
    something complex within a cell like few controls, icons, labels,
    links etc.

  • Datagrid itemRenderer custom component formatting

    OK, so this is my first attempt at an itenRenderer. This works below, but I have to imagine there is an easier way. There is also a problem with below, where the changed field (datafield=side) after the itemRenderer is applied, the text is all out of format, and there is a kind of selection on row one of that column. Obvisouly, though the translation is happening, I'm either overidding the wrong thing, or I'm doing something totally wrong.
    Goal..... Show in the datagrid, the three colums below from date provided from elsewhere. (This all works), but in the 'side' data it comes in, in raw form as either an 'a' or 'b' or 'both', and I'm trying to display that as something more user friendly. So when both is read it changes it to 'No'.
    Any help. This seems really easy, though I can't understanading hy my custom function screws with the cell selection, and formating?
    ---Main program---
    <mx:DataGrid x="10" y="9" width="199" height="147" id="gdimmer_checkChannel" dataProvider="{ current_rack.getItemAt(0).rackLevels }"
      change="dimmerCheckCurrentSelection(event);"
      sortableColumns="false"
      selectedIndex="{ current_rack.getItemAt(0).currentCheckIndex }" >
    <mx:columns>
      <mx:DataGridColumn headerText="UDN" dataField="udn"/>
      <mx:DataGridColumn headerText="DD" dataField="side" editable="false" itemRenderer="renderers.DataGridDDSide"/>
      <mx:DataGridColumn headerText="Circuit" dataField="circuit"/>
    </mx:columns>
    </mx:DataGrid>
    --- Component Below ---
    <?xml version="1.0" encoding="utf-8"?>
    <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            focusEnabled="true">
    <s:Label id="lblData" text="{dataGridListData.label}" />
    <fx:Script>
    <![CDATA[
      override public function set data(value:Object):void
        if (value.side == 'both') { lblData.text = "  No" };
       if (value.side == 'a') { lblData.text = "  a" };
       if (value.side == 'b') { lblData.text = "  b" };
    ]]>
    </fx:Script>
    </s:MXDataGridItemRenderer>

    See the latest post on my blog.  You also need to set super.data in the data
    setter.
    Alex Harui
    Flex SDK Team
    Adobe System, Inc.
    http://blogs.adobe.com/aharui

  • WPF - Format DataGrid column as currency - WPF

    Hi,
    I have a WPF DataGrid that is populated with data from an access database.
    What I want to do is format all cells in a certain column to the currency format (2 decimal places {0:C} i think)
    In the access database the format is set to currency and it doesn't  show up in the database
    Also, is there a way to specify Australian currency so that it rounds to the nearest 5 cents and has 2 decimal places.
    I used this to format the Date and time correctly but I am unsure how to format for currency:
    private void DgvInventoryData_OnAutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
    if (e.PropertyType == typeof (DateTime))
    ((DataGridTextColumn) e.Column).Binding.StringFormat = "dd/MM/yyyy";
    Thanks for all the help in advance...
    From, Nathaniel Peiffer

    Hi,
    Thanks for the answer but the Data in the DataGrid is not from Data Binding it is from an access database using SQL queries and OleDb stuff.
    I am looking for a solution that is in the C# code because I want the user to be able to change the formatting at their leisure.
    So i don't really know how to do the xaml stuff, mainly the C# code
    From, Nathaniel Peiffer

  • How to use datagrid labelfunction to format currency

    So are I'm displaying item prices in a datagrid. I want to format the price to 2 decimal places and display a $. Here's the code i have so far. btw, it's not working. Please tell me what I'm missing.
    Here's my call to the labelfunc:
    <mx:DataGridColumn dataField="value" headerText="Price" labelFunction="price_labelFunc"/>
    Here's my formatter:
      <mx:CurrencyFormatter id="Price"
                precision="2"
                rounding="none"
                decimalSeparatorTo="."
                thousandsSeparatorTo=","
                useThousandsSeparator="true"
                useNegativeSign="true"
                currencySymbol="$"
                alignSymbol="left"/>
    Here's my labelfunc:
    public function price_labelFunc(item:Object, column:DataGridColumn):String
                return Price.format(item.value);
    The label for the price is being returned in an arraycollection at "value".
    ie. value= 567.13445666666
    Thanks in advance for your assistance.

    I've used your code, which seems to be ok. Here is the sample,
    <mx:DataGrid id="dg" dataProvider="{_acItem}">
         <mx:columns>
              <mx:Array>
                   <mx:DataGridColumn headerText="Item" dataField="item"  />
                   <mx:DataGridColumn headerText="Price" dataField="price" labelFunction="formatPrice" />
              </mx:Array>
         </mx:columns>
    </mx:DataGrid>
    <mx:CurrencyFormatter id="cfPrice"
                precision="2"
                rounding="none"
                decimalSeparatorTo="."
                thousandsSeparatorTo=","
                useThousandsSeparator="true"
                useNegativeSign="true"
                currencySymbol="$"
                alignSymbol="left"/>
    [Bindable]private var _acItem:ArrayCollection
    public function init():void {
         var item: Object;
         _acItem = new ArrayCollection();
         item = {item:"PC", price:"1000.99"};
         _acItem.addItem(item);
         item = {item:"Laptop", price:"567.13545666666"};
         _acItem.addItem(item);
    private function formatPrice(value: Object, column: DataGridColumn): String {
         return cfPrice.format(value.price);

  • Formatting a field before committing from editable datagrid

    Hi,
    I have an editable DataGrid which displays two columns, date
    and value. Now, the date in the dataProvider is actually stored as
    an integer (yyyymmdd) so I format it using a labelFunction to
    display. I then have a custom itemEditor to set it to a date for
    calling into the DateField.
    The next step, and where I'm struggling, is to update the
    dataProvider with an integer (yyyymmdd) calculated from the
    selectedDate. Can someone please help me with how to do this?
    Thanks!

    See the docs for data grid editing events, such as, I think,
    itemEndEdit.

  • Datagrid and percentage formatting

    I am having some difficulty rendering percentages in the
    DataGrid. I have the following JSON file structure:
    {"n":"Zimbabwe",
    "o":"63%",
    "m":"38%",
    "g":"1,900"
    When I import these values into the DataGrid, there is a
    problem when I try to sort the percentage columns. The percentages
    are not sorted in the correct order, resulting in something like
    this:
    0%
    100%
    14%
    17%
    etc..
    Instead of:
    0%
    14%
    17%
    100%
    So, I tried changing the JSON file to:
    {"n":"Zimbabwe",
    "o":"63",
    "m":"38",
    "g":"1900"
    However, now I am having problems getting Flex to display a
    percentage symbol next to the numbers in the DataGrid. Any idea
    what I need to do to get this working? What is the right approach
    to take when working with number formatting in the DataGrid? Should
    I be formatting the numbers inside the data source before feeding
    into Flex, or should I be storing the raw numbers in the JSON file
    and then formatting them with Flex?
    Great if someone can point me in the right direction, because
    I really can't find any information about it anywhere on the
    Internet.
    Many thanks!

    My advice is not to pass strings where you actually want to
    pass a integer/float.
    So best is to pass this :
    {"n":"Zimbabwe",
    "o":"63",
    "m":"38",
    "g":"1900"
    Then use a item renderer to render the values as percentage
    values.
    Ries
    Here is my ProcentualRenfderer.mxml
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    implements="mx.controls.listClasses.IDropInListItemRenderer,mx.managers.IFocusManagerComp onent">
    <mx:Script>
    <![CDATA[
    import mx.controls.listClasses.ListData;
    import mx.controls.dataGridClasses.DataGridListData;
    import mx.controls.listClasses.BaseListData;
    import mx.controls.dataGridClasses.DataGridItemRenderer
    import mx.events.FlexEvent;
    private var _listData:DataGridListData;
    // Implement the drawFocus() method for the VBox.
    override public function drawFocus(draw:Boolean):void {
    followUpCB.setFocus();
    [Bindable] private var _numDigits:Number = 2;
    [Bindable]
    override public function set data(value:Object):void{
    super.data = value;
    followUpCB.text=Math.round(data[_listData.dataField] *
    (Math.pow(10,_numDigits)) ) / (Math.pow(10,_numDigits)) + '%';
    override public function get data():Object {
    return super.data;
    public function get listData():BaseListData
    return _listData;
    public function set listData(value:BaseListData):void
    _listData = DataGridListData(value);
    public function set numDigits(value:Number):void {
    _numDigits = value;
    public function get numDigits():Number {
    return _numDigits;
    ]]>
    </mx:Script>
    <mx:Label id="followUpCB" textAlign="right"
    width="100%"/>
    </mx:VBox>

  • Datagrid Cell Format

    Can somebody please help me out (In WPF for absolute DUMMIES fashion) how I can achieve the following:
    I have a DataGrid that I add market data to under the following column Headings:
    Updated, Volume, Price
    I want to format the volume cell whenever the volume value in that cell is 1) between certain values and 2) Greater than a certain value (Similar to conditional formatting of cells in Excel).
    I have tried this:
    <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Style.Triggers>
                                    <Trigger Property="Text" Value="10">
                                        <Setter Property="Background" Value="LightGreen"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
    But the problem is I need to use 'BETWEEN' and 'GREATER THAN', and as you can see, the Value is '=10'
    I have gone through many solutions people have posted using IValueConverter
    but I keep getting errors that I can't seem to resolve. Can someone please provide a walkthrough, or a link to a walkthrough in REAL MONKEY STUPID SIMPLE fashion for someone trying to learn WPF. Thank you!

    There is no >= operator not <= operator available in XAML so you need to use a converter here.
    1. Create a class that implements the IValueConverter. The Convert method should return true or false:
    using System;
    using System.Windows.Data;
    namespace WpfApplication22
    class MyConverter : IValueConverter
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
    decimal d = System.Convert.ToDecimal(value);
    return d >= 10;
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
    throw new NotImplementedException();
    2. Use a DataTrigger in the style that sets the background to some colour if the converter returns true/false:
    <DataGrid
    xmlns:local="clr-namespace:WpfApplication22" ... >
    <DataGrid.Resources>
    <local:MyConverter x:Key="conv"/>
    </DataGrid.Resources>
    <DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding Price}">
    <DataGridTextColumn.ElementStyle>
    <Style TargetType="{x:Type TextBlock}">
    <Setter Property="Background" Value="LightGreen"/>
    <Style.Triggers>
    <DataTrigger Binding="{Binding Path=Price, Converter={StaticResource conv}}" Value="False">
    <Setter Property="Background" Value="Red"/>
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </DataGridTextColumn.ElementStyle>
    </DataGridTextColumn>
    </DataGrid.Columns>
    </DataGrid>
    In the code sample above, the DataGridTextColumn is bound to a source property named "Price" that is of type decimal. You must change the name of the property and the type of d in the Convert method if you are using another name/type.
    The Background is set to Red or LightGreen depending on whether the value of the Price source property >= 10.
    Please refer to the following links for more information about converters:
    https://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(v=vs.110).aspx
    http://www.wpf-tutorial.com/data-binding/value-conversion-with-ivalueconverter/
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • Format columns of Datagrid to TimeFormat

    Hello I have a data grid which I populated dynamically using
    array.
    I have 1 of the column (its header is mytime).
    But the time is displayed as : Thu Jan 1 20:03
    I want my time format to be as such : 20:03 AM/PM
    Please help me how can I format the whole column of a
    datagrid.
    Thx

    <mx:Script>
    <![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
    import mx.formatters.NumberFormatter;
    import mx.formatters.DateFormatter;
    protected function MyRenderer(row:Object,
    column:DataGridColumn):String{
    return nf.format(row[column.dataField ]);
    protected function dateFormat(dateItem:Object,
    column:DataGridColumn):String
    return publishDate.format(dateItem[column.dataField]);
    ]]>
    </mx:Script>
    <mx:Style source="style.css" />
    <mx:DateFormatter id="publishDate"
    formatString="MM/DD/YYYY JJ:NN:SS" />
    <mx:NumberFormatter id="nf"
    precision="2"
    rounding="up"
    decimalSeparatorTo="."
    thousandsSeparatorTo=","
    useThousandsSeparator="true"
    useNegativeSign="true"/>

  • DataGrid: Date Format

    I have a data grid with several date columns.  I would like to format the date yyyy-mm-dd in one column, yet in another column I would like to format the date as mmm/dd/yy.  How can I set these formats in their respective DataGrid columns?

    one way is format yourdataProvider and then feed it to your dataGrid.
    like
                var formattedDate:DateFormatter = new DateFormatter();
                formattedDate.formatString = "YYYY-MM-DD";  
                formattedDate.format(dataProvider[ii].toString());
                var formattedDate:DateFormatter = new DateFormatter();
                formattedDate.formatString = "MMM/DD/YY";  
                formattedDate.format(dataProvider[ii].toString());
    Thanks

  • How to format date and currency datafield in a Datagrid

    Hy folks
    I am getting my data from a web service (against a SQL server)
    After that convert the data in an ArrayCollection and
    Finally I use the ArrayCollection in a Datagrid ussing somethig like :
    <mx:collumns >
    <mx:DataGridcolumn datafield="EnvoiceDate" />
    <mx:DataGridcolumn datafield="EnvoiceValue" />
    How can I format a date tipe datafield in a Datagrid.
    I need to display da date in an format like  DD/MM/YYYY   ex     12/10/2009.
    I also need to display da number like 1345.87   as  1.345,87
    thanks in advance

    Binoy,
    create fields that refer to DATS and TIMS data types
    Thanks
    Bala Duvvuri
    Edited by: Bala Duvvuri on Aug 5, 2010 10:28 PM

  • Format numbers in datagrid as fractions?

    I'd like to have a custom formatter to take numbers displayed
    in a column of my DG as fractions (e.g. 0.5 as 1/2).
    I had tried this in the past, modifying an existing
    formatter. And while I got it to work with text fields, I couldn't
    get it to work in a datagrid. I'm sure I must be missing something
    obvious...
    This code works:
    <comp:FractionFormatter id="makeFraction"
    myNumber="{0}"/>
    <mx:TextInput id="myTI"/>
    <mx:TextArea text="Formatted string is
    {makeFraction.format(myTI.text)}"/>
    But this does not:
    <mx:DataGridColumn dataField="{makeFraction.format(data)}"
    headerText="Amount" width="40"/>
    My formatter:
    quote:
    package myComponents
    //Import base Formatter class
    import mx.formatters.Formatter
    public class FractionFormatter extends Formatter {
    // Declare the variable to hold the pattern string.
    public var myNumber:String;
    // Constructor
    public function FractionFormatter() {
    // Override format().
    override public function format(value:Object):String {
    //Validate value - it must be a nonzero length string.
    if(value.length == 0) {
    // Return empty string and error message for zero-length
    string.
    error="Zero Length String";
    return ""
    //If the value is valid, format the string.
    switch (myNumber) {
    case ".25" :
    return "1/4";
    break;
    case ".5":
    return "1/2";
    break;
    case ".75":
    return "3/4";
    break;
    case "1":
    return "1";
    break;
    case "1.25":
    return "1 1/4";
    break;
    default :
    // If formatString is not "upper" or "lower",
    // return empty string and set the error message.
    error="Invalid Format String";
    return "";

    Actually, the fact that it's a string works for me here,
    since my custom formatter expects a string.
    That's the one last thing I'm confused about. Following the
    example I got from a book, I made my formatter. And it was the
    place I got the "myNumber" thing. So how would I modify my
    FractionFormatter.as to eliminated the need to pass the string from
    the main file (if I understand correctly):
    package myComponents
    //Import base Formatter class
    import mx.formatters.Formatter
    public class FractionFormatter extends Formatter {
    // Declare the variable to hold the pattern string.
    public var myNumber:String;
    // Constructor
    public function FractionFormatter() {
    // Call base class constructor.
    super();
    // Override format().
    override public function format(value:Object):String {
    //Validate value - it must be a nonzero length string.
    if(value.length == 0) {
    // Return empty string and error message for zero-length
    string.
    error="Zero Length String";
    return ""
    //If the value is valid, format the string.
    switch (myNumber) {
    case ".25" :
    return "1/4";
    break;
    case ".5":
    return "1/2";
    break;
    case ".75":
    return "3/4";
    break;
    case "1":
    return "1";
    break;
    case "1.25":
    return "1 1/4";
    break;
    default :
    // If formatString is not "upper" or "lower",
    // return empty string and set the error message.
    error="Invalid Format String";
    return "";
    }

  • Change drag 'n' drop format in a datagrid (or other list based control)

    I want to use the built in drag'n'drop support in the data grid, but it uses the format of "items". Is there any way to change the format that a list control uses for the drag source?

    I think you need to tweak the default drag and drop behavior manually.
    http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_5.html
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services

Maybe you are looking for