在Ext JS4中不能设置UserName字段的输入类型

Not Able to Set Inputtype for UserName Field in Ext JS4

本文关键字:字段 输入 类型 UserName 设置 Ext JS4 不能      更新时间:2023-09-26

我正在使用Extjs 4,我想在我的登录页面自动键入值?

我的代码在下面,我正在设置用户名和密码的文本

当我尝试在GUI的登录页面检索UserName值没有填充标记

马克和杰西都在填写和自动输入密码

如何在相应的字段中实际设置代码

Login.js

Ext.onReady(function(){
        Ext.QuickTips.init();

 items: [
               {
                                        xtype: 'textfield',
                                         fieldLabel: 'UserName',
                                        name: 'j_username',
                                        id: 'lf.txt.username', //Trying to pass Value for this id in GUI as Mark
                },
                {
                                        xtype: 'textfield',
                                        inputType: 'password',
                                        fieldLabel: 'Password',
                                        name: 'j_password',
                                        id: 'lf.txt.password',//Trying to pass Value for this id in GUI as Jessey When i Launch Code 
                 }
 ]
}
}

当我尝试在我的Login.Html页面

中使用上述值时

Like Below INdex.js

{
 var userName = Ext.getCmp('lf.txt.username');
       alert(userName);
       // alert(lf.txt.password);  // It is Gettin UserName as MArk 
        t.diag(userName.title);
        t.type(userName, 'Mark');
        var password = Ext.getCmp('lf.txt.password');
        alert(password); // It is Gettin password as Jessey Correctly 
        t.diag(password.title);
        t.type(password, 'Jessey');
}

但是我只能在密码字段中打印用户名和密码!

我能够打印两个马克和杰西在密码字段,但不是用户名?

谁能告诉我如何设置用户名的值在.js页面?

让我知道如何将用户名和密码值传递到各自的字段?

您获得组件本身与Ext.getCmp函数。你应该得到Ext.getCmp(cmpId).getValue()的输入值。顺便说一下,我看不到任何容器的输入字段?我认为这个代码不能正常工作。如果你正在处理输入,建议使用表单面板;然后使用表单面板的功能获取输入。

一个工作示例应该是这样的:

var form = Ext.create('Ext.form.Panel', {
    title : 'A title',
    items : [{
       xtype : 'textfield',
       name  : 'input1',
       fieldLabel: 'Label1'
    }, {
       xtype : 'textfield',
       name  : 'input2',
       fieldLabel: 'Label2'
    }]
});
form.getForm().findField('input1').getValue();