Number Field

  1. #1

    Number Field

    Hi !

    I've just downloaded v0.7 and I'm trying to use the NumberField component but I have some questions:

    1. How to right align the number as we type ?

    2. When the field looses focus, the values (decimal part) finished with 0 (zero) is not showed e.g.:

    100.45 -> 100.45 but 100.00 -> 100 and I would like all numbers could be with 2 decimal.

    PS. Where is the "ProgressBar" example at the "Examples Explorer" ?

    Thank's

  2. #2

    RE: Number Field

    Hi,

    Please see the following example (please note that formatting applies on blur event)
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Example</title>
        
        <style type="text/css">
            .rmoney
            {
                text-align:right;
            }
        </style>
        
        <script type="text/javascript">        
             function toMoney(field) {
                if (field.getValue() == '') {
                    return;
                }
                
                var value = Ext.util.Format.usMoney(field.getValue());
                field.setRawValue(value.replace('$',''));
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:NumberField runat="server" Cls="rmoney">
                <Listeners>
                    <Blur Fn="toMoney" />
                </Listeners>
            </ext:NumberField>
        </form>
    </body>
    </html>

  3. #3

    RE: Number Field

    Setting the StyleSpec property would be another option for aligning the text.

    Example


    StyleSpec="text-align: right;"

    Hope this helps.


    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Number Field
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 19
    Last Post: Jul 19, 2011, 8:59 AM
  2. [CLOSED] Number Field
    By majestic in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 05, 2011, 12:21 PM
  3. [CLOSED] Number field Error
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 22, 2010, 5:42 AM
  4. [FIXED] Number field culture bug
    By markvb in forum Bugs
    Replies: 3
    Last Post: Jun 11, 2010, 1:07 PM
  5. [CLOSED] Nullable number field
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 02, 2010, 5:06 PM

Posting Permissions