Search code examples
javascriptextjsextjs6-classic

ExtJS listConfig doesn't work in itemselector


Config listConfig doesn't work in the itemselector component. I want to change class for items inside.

My code:

{
  xtype: 'itemselector',
  name: 'itemselector',
  allowBlank: false,

  fieldLabel: 'ItemSelector',
  displayField: 'text',

  store: ds,
  valueField: 'value',
  value: ['3', '4', '6'],

  listConfig: {
    itemCls: 'my-class'
  },

  anchor: '100%',
  msgTarget: 'side'
}

Solution

  • This is an old problem, in order to the listConfig to work, you need to override the function create list in the itemSelector and add the listConfig, like this:

        Ext.override(Ext.ux.form.ItemSelector, {
    
            createList: function(title){
                var me = this;
    
                return Ext.create('Ext.ux.form.MultiSelect', {
                    // We don't want the multiselects themselves to act like fields, 
                    // so override these methods to prevent them from including 
                    // any of their values 
                    submitValue: false,
                    getSubmitData: function(){
                        return null;
                    },
                    getModelData: function(){
                        return null;    
                    },
                    flex: 1,
                    dragGroup: me.ddGroup,
                    dropGroup: me.ddGroup,
                    title: title,
                    store: {
                        model: me.store.model,
                        data: []
                    },
                    displayField: me.displayField,
                    valueField: me.valueField,
                    disabled: me.disabled,
    
                    //Add this config =================
                    listConfig: me.listConfig,
                    //=================================
    
                    listeners: {
                        boundList: {
                            scope: me,
                            itemdblclick: me.onItemDblClick,
                            drop: me.syncValue
                        }
                    }
                });
            }
        });