[CLOSED] NumberField bug or work as wanted?

  1. #1

    [CLOSED] NumberField bug or work as wanted?

    Hello

    See that:

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
        
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>TimeField Control Variations - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <script  type="text/javascript" language="javascript">
            var ValueSpinUp = function ()
            {
                alert("SpinUp " + App.nbTest.value);
            }
    
            var ValueSpinDown = function ()
            {
                alert("SpinDown " + App.nbTest.value);
            }
    
            var ValueSpin = function ()
            {
                alert("Spin " + App.nbTest.value);
            }
    
        </script>
    
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="en-US" />
           
            <ext:NumberField
                id="nbTest"
                runat="server"
                Text="10">
            <Listeners>
                <SpinUp Fn="ValueSpinUp"></SpinUp>
                <SpinDown Fn="ValueSpinDown"></SpinDown>
                <Spin Fn="ValueSpin"></Spin>
            </Listeners>
            </ext:NumberField>
    
           
        </form>
        
    </body>
    When entering the 3 events, the value of the Number field is not increased/decreased, it is after events are fired, so the only way to use the spinup/spindown value is to add or substract 1 from the getted value, and it render usefull the use of the spin event because when used we didnd't know if it is up or down.

    So the question in title.
    Last edited by Daniil; Oct 18, 2012 at 1:14 PM. Reason: [CLOSED]
  2. #2
    Hi @feanor91,

    "alert()" can break spinners. As it happens when I tried your page in FireFox and click a spinner - an alert box just goes in cycles.

    Please try with console.log() or Ext.Msg.alert() instead. Is it still reproducible?
  3. #3
    OK, but into my code i have no alert, look:

    var seekRMA = function (RMA)
    {
        var RMA=App.txtRMAToSeek.value
        var sto = Ext.getStore("stoAdminPFVM");
        var Proxy = sto.getProxy();
    
        Proxy.url = './jsonDAL/returnJSONAdminPFVM.aspx?RMA=' + RMA;
        sto.setProxy(Proxy);
        sto.load();
    }
    txtRMAToSeek is my NumberField, and when I use spiner, I have exactly the same phenomenom than example I post.

    I will say that the value is updated after the function is trigered.

    I put an alertbox just to show my point.
  4. #4
    Unfortunately, I can't reproduce the issue using your sample, because an alert box just goes in cycles for me.

    Could you provide a sample without "alert"?

    Regarding the seekRMA function.

    Please use the getValue method instead of the value property.

    Also I think that you can replace
    var Proxy = sto.getProxy();
     
    Proxy.url = './jsonDAL/returnJSONAdminPFVM.aspx?RMA=' + RMA;
    sto.setProxy(Proxy);
    sto.load();
    with just
    sto.reload({
        url: 'a new URL'
    });
  5. #5
    Without alert and add getValue to see if different from value:


    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
        
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>TimeField Control Variations - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <script  type="text/javascript" language="javascript">
            var ValueSpinUp = function ()
            {
                console.log("SpinUp (nbTest.value)" + App.nbTest.value);
                console.log("SpinUp (nbTest.getValue)" + App.nbTest.getValue());
            }
    
            var ValueSpinDown = function ()
            {
                console.log("SpinDown (nbTest.value)" + App.nbTest.value);
                console.log("SpinDown (nbTest.getValue)" + App.nbTest.getValue());
            }
    
            var ValueSpin = function ()
            {
                console.log("Spin (nbTest.value)" + App.nbTest.value);
                console.log("Spin (nbTest.getValue)" + App.nbTest.getValue());
            }
    
        </script>
    
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="en-US" />
           
            <ext:NumberField
                id="nbTest"
                runat="server"
                Text="10">
            <Listeners>
                <SpinUp Fn="ValueSpinUp"></SpinUp>
                <SpinDown Fn="ValueSpinDown"></SpinDown>
                <Spin Fn="ValueSpin"></Spin>
            </Listeners>
            </ext:NumberField>
    
           
        </form>
        
    </body>
    Result: same thing
  6. #6
    Confirm. A NumberField value is changed after triggering spin listeners.

    What about to use a Change listener?
    http://docs.sencha.com/ext-js/4-1/#!...d-event-change
  7. #7
    Quote Originally Posted by Daniil View Post
    Confirm. A NumberField value is changed after triggering spin listeners.

    What about to use a Change listener?
    http://docs.sencha.com/ext-js/4-1/#!...d-event-change
    It sounds like a bug for me, what is the interest to trigered event that do nothing? OK, it is possible to add/substract 1 in the event but the job will be made 2 times, on in our code and one int the numberfield code. But perhaps it is not possible to add/sbsract one before the event due to some javascipt limitation, I don't know.

    About the change event, I will look a to see if it works better.

    EDIT:

    it works with change event.

    Also I think that you can replace
    1
    2
    3
    4
    5
    var Proxy = sto.getProxy();

    Proxy.url = './jsonDAL/returnJSONAdminPFVM.aspx?RMA=' + RMA;
    sto.setProxy(Proxy);
    sto.load();
    with just
    1
    2
    3
    sto.reload({
    url: 'a new URL'
    });
    What is the advantage between yout method and mine?
  8. #8
    Quote Originally Posted by feanor91 View Post
    It sounds like a bug for me, what is the interest to trigered event that do nothing?
    Well, these Spin events appeared in the SpinnerField.
    http://docs.sencha.com/ext-js/4-1/#!....field.Spinner

    The NumberField class is a subclass of the SpinnerField one. It uses these Spin events internally for changing a current value. When you assign your own Spin listeners, it is executed before the internal ones, i.e. before changing the value. There is the Change event for your needs.

    Quote Originally Posted by feanor91 View Post
    What is the advantage between yout method and mine?
    There are several ones:

    1. Less code =>
    2. More clarify
    and
    3. Better performance
  9. #9
    OK, thanks to clarify

Similar Threads

  1. Replies: 0
    Last Post: Jun 08, 2010, 6:55 AM
  2. [CLOSED] DecimalPrecision does NOT work on a NumberField
    By jsemple in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 31, 2009, 3:06 AM
  3. Replies: 2
    Last Post: Mar 16, 2009, 1:50 PM

Posting Permissions