ExtJS listConfig在itemselector中不起作用

时间:2018-08-03 15:25:40

标签: javascript extjs extjs6-classic

配置listConfigitemselector组件中不起作用。我想更改内部项目的类。

我的代码:

{
  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'
}

1 个答案:

答案 0 :(得分:1)

这是一个老问题,为了使listConfig能够正常工作,您需要在itemSelector中覆盖函数创建列表并添加listConfig,如下所示:

    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
                    }
                }
            });
        }
    });