tech_enthusiast
tech_enthusiast

Reputation: 693

not able to set value in Ext.window.Window

I tried to set the values using Ext.ComponentManager but it did not work. Here is my code.. I want to set the value of firstname from id. I am getting the id value from server, but not able to set that in firstname and lastname fields. Please help.

Ext.define('sample.view.student.Edit', {
extend : 'Ext.window.Window',
alias : 'widget.studentedit',




requires : ['Ext.form.Panel', 'Ext.form.field.Text',
        'Ext.form.field.ComboBox'],




title : 'student dtls',
layout : 'fit',
autoShow : true,
width : 280,




iconCls : 'icon-user',




initComponent : function() {
    this.items = [{
        xtype : 'form',
        padding : '5 5 0 5',
        border : false,
        style : 'background-color: #fff;',




        fieldDefaults : {
            anchor : '100%',
            labelAlign : 'left',
            allowBlank : false,
            combineErrors : true,
            msgTarget : 'side'
        },




        items : [ {
                    xtype : 'textfield',
                    name : 'studentId',
                    fieldLabel : 'studentId',
                    listeners : {
                        blur : function() {
                            //    fnDataForm(this.value);
                            Ext.Ajax.request({
                                url : 'student/fetchDtls.action',
                                params : {
                                    guiInstrId : this.value
                                },
                                success : function(response, opts) {
                                    var jsonResp = Ext
                                            .decode(response.responseText);




                                    console.dir(jsonResp);
                                    console.log(jsonResp.studentFirstName);
                                    // How to set jsonResp.studentFirstName value in below textfield ?
                                    this.up('form').getForm().getValues().studentFirstName.setValue(jsonResp.studentFirstName);
                                },
                                failure : function(response, opts) {
                                    console
                                            .log('server-side failure with status code '
                                                    + response.status);
                                }
                            });
                        }
                    }




                }, {
                    xtype : 'textfield',
                    name : 'studentFirstName',
                    fieldLabel : 'student First Name'




                }, {
                    xtype : 'textfield',
                    name : 'studentLastName',
                    fieldLabel : 'student Last Name'




                }]
    }];

Upvotes: 0

Views: 518

Answers (1)

tech_enthusiast
tech_enthusiast

Reputation: 693

I had to put this in my code and then it worked like charm. Let me know if anyone also has the same problem.. It might help you too...

{
xtype: 'textfield',
name: 'studentFirstName',
itemId: 'studentfirstname',
fieldLabel: 'student First Name'
}

..

 var form = this.up('form'),
  sfn = form.down('#studentfirstname');

sfn.setValue(sonResp.studentFirstName);

Upvotes: 2

Related Questions