Results 1 to 8 of 8

Thread: How to reinitialize combobox

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
      0  

    Default How to reinitialize combobox

    Dear community, help me resolve this trouble

    Code:
    #combobox
    constructor: function (config){
            config.store = Ext.create('Ext.data.Store', {
                    fields: [],
                    proxy: {...}
            });
            config.store.on('load', function(store, records, status){
                            fields = Ext.Object.getKeys(store.first().raw);
                            store.model.setFields(fields);
                            var displayField = 'any property name from fields array';
                            this.displayField = displayField; //do not help
                            this.getPicker().displayField = displayField; //do not help
                            //what i need to here to reinitialize combobox 
                            //and that new displayField using
            }, this);
            this.callParent(arguments);
    }

  2. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Answers
    67
    Vote Rating
    284
      0  

    Default

    AFAIK, there is no way to reconfigure it out of the box. You are better off removing the existing combo and replacing it with a new one than trying to hack it to work.

  3. #3
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    44
      0  

    Default

    Try this:
    PHP Code:
    // The data store containing the list of states
    var states Ext.create('Ext.data.Store', {
        
    fields: ['abbr''name'],
        
    data : [
            {
    "abbr":"AL""name":"Alabama"},
            {
    "abbr":"AK""name":"Alaska"},
            {
    "abbr":"AZ""name":"Arizona"}
            
    //...
        
    ]
    });

    var 
    states2 Ext.create('Ext.data.Store', {
        
    fields: ['id''title'],
        
    data : [
            {
    "id":"1""title":"11111"},
            {
    "id":"2""title":"22222"},
            {
    "id":"3""title":"33333"}
            
    //...
        
    ]
    });

    // Create the combo box, attached to the states data store
    var Ext.create('Ext.form.ComboBox', {
        
    fieldLabel'Choose State',
        
    storestates,
        
    queryMode'local',
        
    displayField'name',
        
    valueField'abbr',
        
    renderToExt.getBody()
    });
    Ext.create('Ext.button.Button', {
        
    text'test',
        
    renderToExt.getBody(),
        
    handler: function () {
            
    c.reset();
            
    c.displayField 'title';
            
    c.valueField 'id';
            
    c.picker.destroy(); // Destroy old picker
            
    c.createPicker(); // Recreate picker
            
    c.bindStore(states2true); // Bind new store
        
    }
    }); 

  4. #4
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    44
      0  

    Default

    Dont work if store instance same =(
    Last edited by redraid; 19 Sep 2012 at 7:32 AM. Reason: fix

  5. #5
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Answers
    67
    Vote Rating
    284
      0  

    Default

    You would also need to replace the displayTpl if you are going that route otherwise when you select it you wont see anything. I still think it is cleaner to simply create a new combo and destroy the old one. Trying to change it requires hackery which is more susceptible to upgrade issues.

  6. #6
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    44
      0  

    Default

    i'm agree the simplest way - recreate combo

  7. #7
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
      0  

    Default

    ??????? ?? ??? ?????. ??? ????? ??????? ?????????? ????? ??? ?????. ?? ???? ??? ??????? ????? ?? ???????, ? ?? ???? ???????? ???: "fields: ['id', 'title'], c.valueField = 'id'".
    ???? ? ???? ??????, ?? ??? ????? ????? ????????? ???? ??? ?????????? ??????? ????????? ? ?????? ??????, ??? ????????????? ?????? ?????? ?????? ? ??? ????????????? ?????????? ? ?????? ??????????????. ? ? ???? ?????? ???? ??? valueField ? ???? ????????? ???? ?????????? ????, ?? displayField ? ???? ????? ???????? ?? ??????? ? ???????.

  8. #8
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Yes i see what displayTpl is compiling at initializing time. I just thought maybe there is an event which force reinitialize component, maybe private method or etc. Or someone know ux combobox with similar effects.

Tags for this Thread

Posting Permissions

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