Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: How to place cursor in a Formfield?

  1. #1
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Default How to place cursor in a Formfield?

    I would like to know how to place a cursor in a Formfield after a window or a page got loaded.

  2. #2

    Default

    Ext.getDom("VARIABLE").focus();

  3. #3
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Default

    This doesn't work.

  4. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257

    Default

    If it's an actual form field, it has a focus method:

    Code:
    Ext.getCmp('myField').focus();
    If that doesn't work, try:

    Code:
    Ext.getCmp('myField').getEl().dom.focus();

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Footnote:

    This only works if the form is rendered!

  6. #6
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Arrow difficult

    @evant: Doesn't work at all, looks like condor's right.

    But even when i try to render it there is no Cursor to be seen in the Formfield.
    I create a window and place the FormPanel inside it.
    Here is my code:
    [code]
    // Formdefinitions
    var username = new Ext.form.TextField({
    id : 'username',
    fieldLabel: '".__("Benutzer")."',
    name: 'username'
    });

    var password = new Ext.form.TextField({
    id : 'password',
    fieldLabel: '".__("Passwort")."',
    name: 'password',
    inputType: 'password'
    });

    var form = new Ext.FormPanel({
    labelWidth: 75, // label settings here cascade unless overridden
    frame: false,
    bodyStyle: 'padding: 5px; background-color: #FFFFFF;',
    height: 60,
    items: [username, password]
    });


    wizard = new Ext.Window({
    id: 'loginframe',
    title: '".__("Login")."',
    closable: false,
    maximizable: false,
    resizable: false,
    modal: true,
    width: 290,
    height: 135,
    bodyStyle: 'padding: 5px;',
    closeAction: 'hide',
    plain: true,
    constrain: true,
    html: '<div id=\"windowdiv\" name=\"windowdiv\"></div>',
    items: [form],
    buttons: [{
    text: '".__("Ok")."',
    disabled: false,
    handler: function () {
    document.getElementById('username').value = username.getRawValue();
    document.getElementById('password').value = password.getRawValue();
    document.getElementById('form').submit();
    // password.setRawValue(document.getElementById('fehler').value);
    }
    }
    ]
    });

    if (document.getElementById('fehler').value !== '') {
    wizard.height = 192;
    wizard.html = '<div style=\"padding: 5px; background: #FFFFFF;\"><b>"
    .__("Achtung")."</b>'+' : '+document.getElementById('fehler').value+'</div>';
    }

    wizard.show();
    form.render();
    Ext.getCmp('username').getEl().dom.focus();

    // Falls enter gedr

  7. #7
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Default

    Anybody a clue? (its urgent)
    There has to be way to do that with Ext. I mean this is something really basic.

  8. #8
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Default

    I get the cursor positioned when i render the FormPanel into a page, but in my case i want to put the FormPanel into a window. In this case there seems to be no way to place the cursor in one of the FormFields.

  9. #9
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257

    Default

    2 things:

    1) Don't call form.render, it gets rendered automatically.

    2) Use this code:

    Code:
    wizard.on('show', function()
    {
       Ext.getCmp('username').focus();
    }, null, {delay: 100});

  10. #10
    Ext User swagner's Avatar
    Join Date
    Jan 2008
    Location
    Munich, Germany
    Posts
    88

    Default

    No, this doesn't work eighter.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •