1. #1
    Sencha User
    Join Date
    Jun 2013
    Posts
    2
    Vote Rating
    0
    hometownnerd is on a distinguished road

      0  

    Default Question about combo box

    Question about combo box


    I am extremely new to ext.js and I am using code that someone else has created that builds a combo box, but what I need is to have the combo box actually auto select an entry in it on load, I have tried to use the render listener but I am facing a new issue. The dropdown actually auto selects as it should but the dropdown seems to use an ID instead of the value stored in the dropdown, how can I force this to auto select. When you normally select the drop down it shows just the username, when it actually getValue it uses the ID, I cannot seem to have it do this through setValue, show the username but set the user id. does this make sense?

    Thanks in advance for any help that can be provided.
    The code is below:
    Code:
    var UserListcbo = new Ext.form.ComboBox({
    id:'UserListcbo',
    fieldLabel: 'Member',
    loadingText:'Please Wait ...',
    store:UsersDataDS,
    mode: 'local',
    forceselection:true,
    displayField: 'username',
    valueField: 'ID',
    anchor:'95%',
    triggerAction: 'all',
    value: 'USERNAME',//this is the username to fill in the dropdown on load
    listeners:{
    select:function(combo,record){
    uid = UserListcbo.getValue();
    username = record.data.username;
    //on user select load trip and pictures for user
    TripDataDS.load({params: {mode: 'TripList',UID: uid}});
    AllPicturesDS.load({params: {mode:'AllPictures',UID: uid}});
    },
    render:function(combo,record){
    uid = USERID;//the user id of the user you want to select
    username = "USERNAME";//the username you want to select
    //on user select load trip and pictures for user
    TripDataDS.load({params: {mode: 'TripList',UID: uid}});
    AllPicturesDS.load({params: {mode:'AllPictures',UID: uid}});
    }    
    
    
    }
    
    
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,219
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thank you for using BBCode CODE tags for your code but you need to ensure it's legible for people to help you and understand your code. Can you restore the indention?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2013
    Posts
    2
    Vote Rating
    0
    hometownnerd is on a distinguished road

      0  

    Default


    Code:
    var UserListcbo = new Ext.form.ComboBox({
       id:'UserListcbo',
       fieldLabel: 'Member',
       loadingText:'Please Wait ...',
       store:UsersDataDS,
       mode: 'local',
       forceselection:true,
       displayField: 'username',
       valueField: 'ID',
       anchor:'95%',
       triggerAction: 'all',
       value: 'USERNAME',//this is the username to fill in the dropdown on load
       listeners:{
                   select:function(combo,record){
                        uid = UserListcbo.getValue();
                        username = record.data.username;
                        //on user select load trip and pictures for user
                        TripDataDS.load({params: {mode: 'TripList',UID: uid}});
                        AllPicturesDS.load({params: {mode:'AllPictures',UID: uid}});
                        },
                render:function(combo,record){
                        uid = USERID;//the user id of the user you want to select
                        username = "USERNAME";//the username you want to select
                        //on user select load trip and pictures for user
                        combo.setValue(uid);
                        
                        TripDataDS.load({params: {mode: 'TripList',UID: uid}});
                        AllPicturesDS.load({params: {mode:'AllPictures',UID: uid}});
                        }        
                        
                }
                
    });
    Sorry, didn't even pay attention to how it looked, thanks! Hope this is better.

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Posts
    8
    Vote Rating
    0
    guilan is on a distinguished road

      0  

    Default Comboboc listener error 'getValue is not a function'

    Comboboc listener error 'getValue is not a function'


    Hi hometownnerd:

    I am completely new in this area. I tried to use your suggestion to solve my problem, but I encountered the error 'getValue is not a function'. My problem is that my combo box always returns the first item not the item selected. Here is the part of my code:
    items: [{
    id: 'banner1',
    xtype: "combo",
    //editable: false,
    width: 700,
    listWidth: 700,
    store: store,
    displayField: 'banner',
    valueField: 'event_id',
    name: 'banner1',
    typeAhead: true,
    mode: 'local',
    forceSelection: true,
    triggerAction: 'all',
    emptyText:'No Banner',
    selectOnFocus:true,
    listeners:{
    select:function(combo,record){
    event_id = banner1.getValue();
    banner= record.data.banner;
    }
    }
    }]

    Any help is appreciated. Thank you for your help in advance.

Thread Participants: 2