1. #1
    Ext User
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    43
    Vote Rating
    0
    dinosauro is on a distinguished road

      0  

    Default setting values to textfields

    setting values to textfields


    Hi,
    I have a form with controls like textfields etc. a data store, read a record and show data in fields, is there a way to put data to controls ?

    Code:
    var ragionesociale = new Ext.form.TextField ({
        //id: 'ragionesociale',
        fieldLabel: 'Denominazione impresa',
        anchor: '97%',
        maxLength: 150,
        selectOnFocus: true,
        //value: "prova",
        maskRe: alfanumMask
        //maskRe: /([a-zA-Z0-9\s]+)$/
    });
    
    etc. etc.
    
    var editFormPanel = new Ext.form.FormPanel ({
        labelAlign: 'top',
        bodyStyle: 'padding:5px',
        items: [{
            layout: 'column',    //column
            border: false,
            items: [{
                columnWidth: 0.5,
                layout: 'form',
                border: false,
                items: [ragionesociale, indirizzo]
            },{
                columnWidth:0.5,
                layout: 'form',
                border: false,
                items: [citta, cap]
            }]
        }],
        buttons: [{
            text: ' Salva ',
            handler: salva
        },{
            text: ' Annulla ',
            handler: annulla
        }]
    });
    
    etc. etc.
    
    impreseDataStore.on('load', function() {
          sql = impreseDataStore.reader.jsonData.sql; //debug
        row = impreseDataStore.reader.jsonData.rows;
        ragionesociale.setValue(row[0].ragionesociale);
        MORE OTHER ASSIGN
    });
    is there a way to substitute assignments field by field ?

    Is it possible to use the field names written in editFormPanel at prop. items: ?

    If isnt possible automatize, i'll write again

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Try:
    Code:
    editFormPanel.getForm().loadRecord(someRecord);
    (this assumes that the record fields and the field names match)
    or
    Code:
    editFormPanel.getForm().setValues(someObject);
    (this assumes that the object properties and the field names match)

Thread Participants: 1