Extjs: How to set value for combobox at boot

  • I am looking for a load listener , which, when the dropdown field is up, will be called load and get ajax for the server to accept the correct displayed value for combobox. But the load function is never called .. how can I fix it?

  • I want to display the text in front of the list, so I added an attribute fieldLabel: 'Save logs to:'. But the text is not displayed.

thanks yoni

this.log_save_combo = new Ext.form.ComboBox
    ({
        store: ['Device', 'USB1', 'USB2']
        , id: 'cplogs_log_save_combo'
        , name: 'cplogs_log_save_combo'
        , triggerAction:'all'
        , fieldLabel: 'Save logs to:'
        , editable: false
        //, value: "Device"
        , listeners: {
                'load': function(){
                        alert("in load function");
              }
    });
+3
source share
5 answers

load . , , , . , .. , ? "combobox is up"?

, . , -.

----------------------------------------- UPDATE ----- ------------------------------------

  • ? , , BasicFrom. . . , XML, JSON.

  • ,

    layout: 'form'

0

,

listeners:{
    scope: this,
    afterRender: this.selectFirstComboItem
}

selectFirstComboItem: function(combo) {
    // This will tell us if the combo box has loaded at least once
    if (typeof combo.getStore().lastOptions !== "undefined") {
        // Grab the first value from the store
        combo.setValue(combo.getStore().first().get(combo.valueField));
    }
    else {
        // When the store loads
        combo.getStore().on("load", function(store, items){
            // Grab the first item of the newly loaded data
            combo.setValue(items[0].get(combo.valueField));
        });
    }
}
+3

, , , , combobox. combo box .

Ext.create('Ext.form.field.ComboBox', {
...
value : this.myStore.first().get('aFieldName')
+1
  • store.load()
  • In the callback, set the value with setValue()

Example:

store.load({
        callback: function () {
             form.findField('name_of_the_combo').setValue('your_value');
         }
    });
0
source

There is no loading event for combos. What you can do is load the data into a combo from the repository when loading your form. After that, you can set the field level on the selected combo event.

Example:

listeners:{
    select: function(){
       Ext.getCmp('id_of_the_field')
      .getEl()
      .down('label.x-form-cb-label')
      .update('Save logs to:');                             
    }
}
0
source

All Articles