[CLOSED] Numberfield cant receive focus

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Numberfield cant receive focus

    Hello members

    I was wondering if anybody have come a cross this problem before.

    I have a field that can not recive focus after a form has been closed and then the same form is reopened.

    the senario is that when i open the form for the first time my field can recive focus and marks the text.

    But after i have made a submit / save of the data and reopens the form again the field cant recieve focus.

    i have not override the fields default OnFocus method since i rely on the default implementation and use SelectOnFocus.

    My Field code looks like this..

      
                this.ID = Name + "_Time";
                this.MaxValue = Convert.ToDouble("23,59");
                this.MinValue = Convert.ToDouble("00,00");
                this.Step = 0.01;
                this.FieldLabel = label;
                this.SelectOnFocus = true;
                this.Listeners.Blur.Fn = "LIA.Time.OnBlur";
                this.Listeners.Spin.Fn = "LIA.Time.Change";
                this.CustomConfig.Add(new ConfigItem("type", "liaTimeField", ParameterMode.Value));
                this.CustomConfig.Add(new ConfigItem("forcePrecision", "true", ParameterMode.Value));
    My javascript methods are af following..

    
    LIA.Time.Change = function () {
        this.valueToRaw();
    }
    
    LIA.Time.OnBlur = function () {
        this.valueToRaw();
    }
    I have overriden the methode valueToRaw and the code is like this.

    
    // Overrides Numberfield decimals precision
    Ext.override(Ext.form.NumberField, {
        forcePrecision: false,
    
        valueToRaw: function (value) {
            var me = this,
                decimalSeparator = me.decimalSeparator;
            value = me.parseValue(value);
            value = me.fixPrecision(value);
            value = Ext.isNumber(value) ? value : parseFloat(String(value).replace(decimalSeparator, '.'));
            if (isNaN(value)) {
                value = '';
            } else {
                if (me.type == "liaTimeField") {
                    var hourIndex = String(value).indexOf(".");
                    if (hourIndex == -1) {
                        var hours = value;
                    }
                    else {
                        var hours = String(value).substring(0, String(value).indexOf("."));
                    }
    
                    var step = me.step;
    
                    var stepIndex = String(step).indexOf(".") + 1;
                    var stepDecimal = String(step).substring(stepIndex, String(step).length);
    
    
    
                    var decimalIndex = String(value).indexOf(".") + 1;
                    var decimals = String(value).substring(decimalIndex, String(value).length);
                    var diff = 0;
                    if (decimals.length < 2) {
                        if (decimalIndex == 0) {
                            decimals = "00";
                        }
                        decimals += "0";
                    }
    
                    if (parseInt(decimals) > 59) {
                        if ((parseInt(decimals) + parseInt(stepDecimal)) >= 100) {
                            var number = (parseInt(decimals) + parseInt(stepDecimal));
                            var diffNumber = number - 100;
                            var diff = 60 - (parseInt(stepDecimal) - diffNumber);
                        }
                        else {
                            var diff = decimals - 60;
                            hours++;
                            if (diff < 10) {
                                diff = "0" + diff;
                            }
    
                        }
                        value = me.parseValue(hours + "." + diff);
                    }
                }
                value = me.forcePrecision ? value.toFixed(me.decimalPrecision) : parseFloat(value);
    
                if (me.type == "liaTimeField") {
                    if (hours < 10) {
                        value = String(value);
                        value = "0" + value;
                    }
                }
    
                value = String(value).replace(".", decimalSeparator);
            }
            return value;
        }
    
    })
    Its not a game breaker for me, but i could lead to some unexspecting problem when a person tries to store a given time.

    Regards

    Peter
    Last edited by Daniil; Apr 30, 2013 at 4:13 AM. Reason: [CLOSED]
  2. #2
    Hi Peter,

    Quote Originally Posted by Akpenob View Post
    I have a field that can not recive focus after a form has been closed and then the same form is reopened.
    Reopened? How do you do that? Does it not render a new NumberField with the same id? Just the behavior you describe can be led by an id conflict, i.e. when there are two or more components with the same id.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Peter,


    Reopened? How do you do that? Does it not render a new NumberField with the same id? Just the behavior you describe can be led by an id conflict, i.e. when there are two or more components with the same id.
    I might not have been clear on what i meant with reopen.

    The form that contains the number field is closed and destroyed, but i open anonther (copy / new) one of the same form so there is no id there is identical its just the same form i open again when i want to edit or create a new object.

    So there should not be an issuse since the old form is dead and the new one knows nothing about the old one.

    hope this clears it up a bit.

    Best Regards

    Peter
  4. #4
    Could you provide a full test case to reproduce?
  5. #5
    Quote Originally Posted by Daniil View Post
    Could you provide a full test case to reproduce?
    The short storry is
    sorry i cant.

    The Long story

    The way we handle ext in this project is by scripting the form out to javascript.

    We define the form, its controls and what method it should contain in a standards C# class.

    Then we call to toScript() on the form and send the result to the browser and that way we can create our Form / windows dynamicly.

    When we receive a webmethod call to the server( WFC ) we can trace back to the C# class the method is in and execute it.

    With the sever call we can intepret if we need to create a Window / form or some other components and then we script the result back to the client making it create the components specified or preform the update just as if we where using Extjs.
    Thus avoiding the need to reload the page.

    When a form / window is closed, its acts as normal and destroy is called, like it should via the close method..

    So it would be very hard for me to reproduce the given form without giving you the entire solution.

    One thing i have noticed is that its only in IE this "Bug" behavior is present.

    I Have tested in both Chrome, FF, Safari, IE and Opera

    everyone except IE cant receive focus once the form has been open again..

    the picture i have uploaded displays my problem..

    Before we have reopened the form, it looks like the first picture, it has focus and the text is marked, but once i reopen the form to do a edit or somthing else
    the field becomes like the second picture where the cursor is inside the field and the text does not get marked when you click into it, thus not receving focus.

    Best Regards

    Peter
    Attached Thumbnails Click image for larger version. 

Name:	NumberFieldFocus.png 
Views:	28 
Size:	10.8 KB 
ID:	6009  
  6. #6
    I have uploaded a picture that could help a bit more on to what the problem could be..

    Best Regards

    Peter
    Attached Thumbnails Click image for larger version. 

Name:	NumberFieldFocus2.png 
Views:	34 
Size:	17.8 KB 
ID:	6011  
  7. #7
    Thank you for the details. Now the problem looks clear to understand, but, I am afraid I can help without reproducing.

    Are you able to share a sample online? It could help.
  8. #8
    Quote Originally Posted by Daniil View Post
    Thank you for the details. Now the problem looks clear to understand, but, I am afraid I can help without reproducing.

    Are you able to share a sample online? It could help.
    sure i have send the link in a pm
    and the details how to login it..
  9. #9
    Hello,

    My guess is some of the listeners are not being attached properly when the components are recreated.

    Our policy is to not log into proprietary systems, so best we can do is request again for you to post something in the forums that might help us reproduce the problem. The PM you sent has been deleted.

    I would suggest, build a very simple page on your system that reproduces the problem, then View > Source and paste that code here.
    Geoffrey McGill
    Founder
  10. #10
    Triple check that no JavaScript errors are thrown during the recreation of the components.
    Last edited by geoffrey.mcgill; Apr 19, 2013 at 11:52 AM.
    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Set Focus on NumberField control.
    By Rupesh in forum 1.x Help
    Replies: 28
    Last Post: Apr 04, 2012, 1:03 PM
  2. Replies: 1
    Last Post: Dec 01, 2011, 11:34 AM
  3. Replies: 1
    Last Post: Nov 28, 2011, 2:40 PM
  4. Replies: 2
    Last Post: Sep 22, 2011, 2:13 PM
  5. Replies: 5
    Last Post: Jan 06, 2010, 10:35 AM

Tags for this Thread

Posting Permissions