1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    11
    Vote Rating
    0
    vishnupriya is on a distinguished road

      0  

    Default How to get DataView of a comboBox to make a default selection

    How to get DataView of a comboBox to make a default selection


    Hi,

    Im creating a comboBox for which i want to set the First Element in the View as the Default selection.. I tried combo.select(0), but i get an error that reads "this.view has no properties"..
    I tried creating a dataView, associating with the store im using and assigned it to the comboBox im using, combo.view(myDataView), but din work, as the dataView is not rendered..
    How to go abt this..Plz help..

    <code>
    //Store
    var store = new Ext.data.SimpleStore({
    fields: ['item', 'action'],
    data : CItems
    });

    //combo
    var combo = new Ext.form.ComboBox({
    store: store,
    displayField:'item',
    applyTo: 'combo-action',
    typeAhead: true,
    mode: 'local',
    triggerAction: 'all',
    emptyText:'Select an action...',
    selectOnFocus:true,
    resizable:true,
    listeners:{
    select:{
    fn:function(combo, record, index) {
    var qq= record.get('action').valueOf();
    eval(qq+'('+')');
    }}
    }
    });

    //This doesnt work. says "this.view has no properties"
    combo.select(0, true);
    </code>


    Cheers,
    Vishnupriya

  2. #2
    Ext User santosh.rajan's Avatar
    Join Date
    Sep 2007
    Location
    Kannur, Kerala, India
    Posts
    611
    Vote Rating
    0
    santosh.rajan is on a distinguished road

      0  

    Default


    Set the value of your combobox to your default selection. Or have i not understood your question?
    Make everything as simple as possible, but not simpler.
    - Albert Einstein

  3. #3
    Ext User
    Join Date
    Oct 2007
    Posts
    11
    Vote Rating
    0
    vishnupriya is on a distinguished road

      0  

    Default


    Thanks Santhosh.. It Worked.. This is how i got it done.. Pls let me know if any other efficient way is available..

    var combo = new Ext.form.ComboBox({
    fieldLabel:'Items',
    store: store,
    displayField:'item',
    applyTo: 'combo-action',
    typeAhead: true,
    mode: 'local',
    triggerAction: 'all',
    emptyText:'Select an action...',
    selectOnFocus:true,
    resizable:true,
    value: store.getAt(0).get('item'),
    listeners:{
    select:{
    fn:function(combo, record, index) {
    var qq= record.get('action').valueOf();
    eval(qq+'('+')');
    }}
    }
    });

    Cheers,
    Vishnupriya

  4. #4
    Ext User ArtBuilders's Avatar
    Join Date
    Sep 2007
    Posts
    28
    Vote Rating
    0
    ArtBuilders is on a distinguished road

      0  

    Default Note: Alternative for Remote Data Store

    Note: Alternative for Remote Data Store


    (Sorry for hijaaking but hopefully this will save others some time)
    Note that the solution perscribed above appears to only work for local data stores. If you are retrieving from a database, the store will not be loaded until after a selection is made. Therefore no data will be available to set as default. There are a number of workarounds but, IMHO, the most straight-forward seems to be from Brian.Moeskau...(http://extjs.com/forum/showthread.ph...fault+value%3A).
    I've added a slight modification. Since I am returning the data with the default record on top, I always populate the combobox with the first record (ex. combo.setValue(store.getAt(0).get('field to display')); ):
    PHP Code:
    Ext.onReady(function(){

        var 
    docStore = new Ext.data.JsonStore({
            
    root"FacilityDoctors",
            
    fields: ['doctor_id''doctor_name'],
            
    url'../modules/form/getFormElements.php?action=getDoctorCombo'
        
    }); 
        
        
    docCombo = new Ext.form.ComboBox({
            
    id:'FacilityDoctors',
            
    storedocStore,
            
    displayField:'doctor_name',
            
    typeAheadtrue,
            
    mode'remote',
            
    triggerAction'all',
            
    emptyText:'Select Doctor...',
            
    selectOnFocus:true,
            
    valueField:'doctor_id'
        
    })
        
    docCombo.applyTo('doctor_id')
        
        
    docStore.on('load', function(){
            
    docCombo.setValue(docStore.getAt(0).get('doctor_name')); // always default to first record
            
    docCombo.mode 'local'// load once and cache
        
    }, this, {single:true}); // single to make sure this is only done on initial load
        
        
    docStore.load();
        
    }); 
    Why ask why if the answer is never further from the truth?!!

Thread Participants: 2

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