Results 1 to 5 of 5

Thread: Set FormPanel TextBox Value

  1. #1

    Thumbs up Set FormPanel TextBox Value

    Hi,

    I am unable to set the value of text field on a form using .setValue or .setRawValue.
    Below is my code for my FormPanel:

    Code:
        var customerInfoPanel = new Ext.FormPanel({
            title: "Customer Information",
            collapsible: true,
            frame:true, 
            animCollapse: true,
            defaultType:'textfield',
            labelAlign : 'right',
            labelWidth: 120,
            monitorValid:true,
            items:[
                {
                    fieldLabel: 'Customer Name',
                    id: 'name1',
                    name: 'name',
                    labelStyle: 'font-weight:bolder;',
                    width: 400,
                },{
                    xtype: 'fieldset',
                    title: "Priamry Point of Contact[PPOC]",
                    collapsible: true,
                    autoHeight:true,
                    labelWidth: 105,
                    defaultType:'textfield',
                    width: 540,
                    items:[
                    {
                        fieldLabel: 'PPOC',
                        id: 'ppoc',
                        labelStyle: 'font-weight:bolder;',
                        width:400
                    },{
                        fieldLabel: 'Contact',
                        id: 'ppocContact',
                        labelStyle: 'font-weight:bolder;',
                        width: 400
                    },{
                        fieldLabel: 'Email',
                        labelStyle: 'font-weight:bolder;',
                        id: 'ppocEmail',
                        width: 400
                        
                    }    
                    ]
                }    
            ] 
        });
    I am trying to set the form field values during load event of a datastore:

    Code:
        
        var dscustomerByid = new Ext.data.Store({
            autoDestroy: true,
            reader: new Ext.data.JsonReader({
                fields: ['value', 'customerName', 'ppoc','ppocEmail','ppocContact'],
                root: 'rows'
            }),
            proxy: new Ext.data.HttpProxy({
                url: 'include/getCustomerById.php'
            })
        });
        dscustomerByid.load({params:{id1: rId}});
        dscustomerByid.on("load", function() {
            myResult = dscustomerByid.getAt(0);
            var a =Ext.getCmp('name');
             customerInfoPanel.getForm().findField('name').setValue=myResult.get('customerName');  //no action
               alert(myResult.get('customerName'));  //this returns my field valye
        });
    rId is a variable containg a particular customerID;
    I am just a beginners, so please excuse if I am asking some thing really basic.


    Thanks and best regards,

  2. #2

    Default

    Admin,

    Sorry posted in wrong forum, can someone please move it to Ext3.0 Help Forum

  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    setValue is a method, not a property!

    Code:
    customerInfoPanel.getForm().findField('name').setValue(myResult.get('customerName'));
    (and I don't know if this is relevant, but this only works after the form is rendered)

  4. #4

    Default

    thanks Condor, it worked.

    I think I am tired today, i was just seeing the example code it was exactly the way you told but was writing the code differently.

    one More related question, since this one is working, should following work or not:


    Code:
    var a=Ext.getCmp('name1');
    a.setValue("world");
    name1 is id of txtfield in a FormPanel.I tried but not working.

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    That should work. Are you sure you are not doing anything wrong (you did create the form first?).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •