Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set Value for extjs textfield?

i have a lot of textfields for userdata. and i wish to set it from 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(user.username).then(function(userDetails) {
            me.setTitle("Welcome " + userDetails.mail + "!");
        });

i want to do something like this with value: 'Admin' and so on...

i found some method on Sencha Forum, but can I use it??

setValue: function(value) {
        var me = this;
        me.setRawValue(me.valueToRaw(value));
        return me.mixins.field.setValue.call(me, value);
    },
like image 991
r.r Avatar asked Aug 13 '13 16:08

r.r


People also ask

How do I set the value of a field in Extjs?

setValue. call(me, value); }, extjs.

What is the correct syntax for creating a component in Extjs?

Instantiating Componentsvar panel = Ext. create('Ext. Panel', { html: 'This is my panel' }); This will create a Ext.

What is the xType for EXT Form Panel?

xType defines the type of Ext JS UI component, which is determined during rendering of the component. For example, the element can be a textbox for which we have xType as textField or the element can have a numeric value only for which we have Numeric xType.

What is tooltip in Extjs?

ToolTip is a Ext. tip. Tip implementation that handles the common case of displaying a tooltip when hovering over a certain element or elements on the page. It allows fine-grained control over the tooltip's alignment relative to the target element or mouse, and the timing of when it is automatically shown and hidden.


2 Answers

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');
like image 114
r.r Avatar answered Oct 10 '22 10:10

r.r


Why not just set up a model and store for your form and use the loadRecord method?

like image 38
bakamike Avatar answered Oct 10 '22 10:10

bakamike