Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何设置extjs textfield的值?_Extjs_Set_Textfield_Setvalue - Fatal编程技术网

如何设置extjs textfield的值?

如何设置extjs textfield的值?,extjs,set,textfield,setvalue,Extjs,Set,Textfield,Setvalue,我有很多用于用户数据的文本字段。我想从DB设置它 items: [{ xtype: "form", bodyPadding: 5, border: false, defaults: { xtype: "textfield",

我有很多用于用户数据的文本字段。我想从DB设置它

items: [{
                        xtype: "form",
                        bodyPadding: 5,
                        border: false,
                        defaults: {
                            xtype: "textfield",
                            inputType: "text",
                            anchor: "100%"
                        },
                        items: [{
                            fieldLabel: 'Username:',
                            readOnly: true,
                            value: 'Admin',
                            name: "username"
                        }, {
我使用方法
getUserByUsername()
下面是一个小代码,它将如何在其他视图中使用和工作,但在我的实际视图中,我无法设置textfield的值。请帮忙怎么做

 openDB.getUserByUsername(user.username).then(function(userDetails) {
            me.setTitle("Welcome " + userDetails.mail + "!");
        });
我想用
值执行类似的操作:“Admin”
等等

我在Sencha论坛上找到了一些方法,但我可以使用吗

setValue: function(value) {
        var me = this;
        me.setRawValue(me.valueToRaw(value));
        return me.mixins.field.setValue.call(me, value);
    },

为什么不为您的表单设置一个模型和存储并使用loadRecord方法呢?

经过几个小时的斗争后,使用该->有史以来最好的解决方案:

items: [{
                        fieldLabel: 'Username:',
                        id: 'usernameID',
                        readOnly: true,
                        value: user.username,
                        name: "username"
}]
... 
var name = Ext.getCmp('usernameID').setValue('JohnRambo');
这对我很有用:

ELEMENT.inputEl.dom.value = "000000";

很好,如果您有很多,那么您可以:Ext.Object.each(value,function(key,value){Ext.getCmp(key.setValue(value);});很有魅力!!谢谢buddy.loadRecord()函数需要一条记录,对吗?Ext.store数据的状态可能与表单的状态不同。