How to add to the data received from the server its object? For example, where id = 0, and name = 'None'

modExtra.combo.Categories = function(config) { config = config || {}; Ext.applyIf(config, { name: 'category', hiddenName: 'category', displayField: 'name', valueField: 'id', url: modExtra.config.connector_url, baseParams: { action: 'mgr/categories/getlist' }, fields: ['id', 'name'] }); modExtra.combo.Categories.superclass.constructor.call(this, config); }; Ext.extend(modExtra.combo.Categories, MODx.combo.ComboBox); Ext.reg('modextra-combo-categories', modExtra.combo.Categories); 

UPD Did this:

 modExtra.combo.Categories = function(config) { config = config || {}; Ext.applyIf(config, { name: 'category', hiddenName: 'category', displayField: 'name', id: 'myCountrySearchBox', valueField: 'id', url: modExtra.config.connector_url, baseParams: { action: 'mgr/categories/getlist' }, fields: ['id', 'name'] }); modExtra.combo.Categories.superclass.constructor.call(this, config); /* после загрузки ComboBox присваиваем объекту новые значения в конец списка */ this.store.on('load', function() { this.store.add(new this.store.recordType({ id: null, name: _('modextra_combobox_empty') }, 0)); }, this); }; Ext.extend(modExtra.combo.Categories, MODx.combo.ComboBox); Ext.reg('modextra-combo-categories', modExtra.combo.Categories); 

    2 answers 2

    I usually do this:

     baseParams: { action: 'mgr/categories/getlist', addall: 1 }, 

    in the processor 'mgr/categories/getlist' add

     public function afterIteration(array $list) { $addall = $this->getProperty('addall'); if (!empty($addall)) { $list_all = array( array( 'id' => 0, 'name' => $this->modx->lexicon('modextra.combo.all'), ) ); $list = array_merge($list_all, $list);; } return $list; } 

    and add to translations

     $_lang['modextra.combo.all'] = 'None'; 
    • Thanks for your option! Did this: this.store.on ('load', function () {this.store.add (new this.store.recordType ({id: null, name: _ ('modextra_combobox_empty')}, 0)); , this); - aliokero

    In Ext there are storages, for example, JsonStore. They allow you to add values ​​/ change / delete. Try loading the list in the store, then adding a value, and reconfiguring the drop-down list to this storage.

    I do not remember the details, because Long worked with ExtJs 3.

    Or from the server to return the appropriate list.

    ZY As far as I remember, Ext behind the scenes with such an announcement as you create a simple ArrayStore. It should have events at the end of the download. It may be possible to attach to it and add the desired value.