i have a lot of textfields for userdata. and i wish to set it from DB.
我有很多用户数据的文本域。我想从DB开始设置它。
items: [{
xtype: "form",
bodyPadding: 5,
border: false,
defaults: {
xtype: "textfield",
inputType: "text",
anchor: "100%"
},
items: [{
fieldLabel: 'Username:',
readOnly: true,
value: 'Admin',
name: "username"
}, {
i have external class named openDB.js
with method getUserByUsername()
here is small code how its will be used in other view and it works, but in my actuall view i cant set the Value of textfield. please help how to do that?
我有一个外部类openDB。有getUserByUsername()方法的js这里有一个小代码,它是如何在其他视图中使用的,它可以工作的,但是在我的actuall视图中,我不能设置textfield的值。请帮忙怎么做?
openDB.getUserByUsername(user.username).then(function(userDetails) {
me.setTitle("Welcome " + userDetails.mail + "!");
});
i want to do something like this with value: 'Admin'
and so on...
我想用value做类似的事情:“Admin”等等……
i found some method on Sencha Forum, but can I use it??
我在Sencha Forum上找到了一些方法,但是我可以使用它吗?
setValue: function(value) {
var me = this;
me.setRawValue(me.valueToRaw(value));
return me.mixins.field.setValue.call(me, value);
},
2 个解决方案
#1
30
after couple hours of fighting with that -> BEST SOLUTION EVER:
经过几个小时的战斗,>的最佳解决方案:
items: [{
fieldLabel: 'Username:',
id: 'usernameID',
readOnly: true,
value: user.username,
name: "username"
}]
...
var name = Ext.getCmp('usernameID').setValue('JohnRambo');
#2
1
Why not just set up a model and store for your form and use the loadRecord method?
为什么不建立一个模型并存储表单并使用loadRecord方法呢?
#1
30
after couple hours of fighting with that -> BEST SOLUTION EVER:
经过几个小时的战斗,>的最佳解决方案:
items: [{
fieldLabel: 'Username:',
id: 'usernameID',
readOnly: true,
value: user.username,
name: "username"
}]
...
var name = Ext.getCmp('usernameID').setValue('JohnRambo');
#2
1
Why not just set up a model and store for your form and use the loadRecord method?
为什么不建立一个模型并存储表单并使用loadRecord方法呢?