1. #1
    Ext User
    Join Date
    Sep 2009
    Posts
    9
    Vote Rating
    0
    nels2k is on a distinguished road

      0  

    Default help with loading JSon to textfield

    help with loading JSon to textfield


    im trying to load some data from JSON file into a textfield as soon as its rendered (load it once the page is loaded).

    im fairly new to extjs and so far i've tried something along the lines of:

    Code:
      emailStore.on('load', function(textfield, record, index) {
            document.getElementById('cc').value = emailStore.getById('cc');
        });
    where emailStore is the store with the fields to be loaded. and cc is the field to be loaded.

    and also tried:
    Code:
    cc.on('load', function(combo, record, index) {
            document.getElementById('cc').value = record.get('cc');
        });
    where cc is the id of the textfield.

    thanks,
    NR

  2. #2
    Sencha User BitPoet's Avatar
    Join Date
    Sep 2008
    Location
    Bavaria
    Posts
    277
    Vote Rating
    1
    BitPoet is on a distinguished road

      0  

    Default


    First off, a store's 'load' event handler always gets passed the store instance itself as the first parameter. So assigning the handler should look like:
    Code:
    emailStore.on('load', function(store, records, options) {
     ...
    });
    The second parameter is an array of all loaded records. If you know you have only one record, you could do
    Code:
      if( records.length > 0 ) {
        document.getElementById('cc').value = records[0].get('cc');
      }
    A store's getById method retrieves a whole record, to assign a value, you need to access an individual entry in the record. Make sure to read the API docs and have a look at the various examples on this page, as well as browse the very good tutorials in the Learning Center at the ExtJS page.

    Finally, if your textfield is an Ext.form.TextField, you need to use Ext.getCmp and setValue instead of assigning to document.getElementById(...).value
    Code:
      Ext.getCmp('cc').setValue(records[0].get('cc'));

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi