Ext 属性 网格,在多选组合中分配了值

Ext property grid with assigned values in multiselectable combos

我正在尝试为 extjs 属性 网格中的多选组合框赋值。当我为该字段分配一些值时,网格无法呈现该字段。如何解决这个问题?请在下面找到代码。

Ext.create('Ext.grid.property.Grid', {
   title: 'Properties Grid',
   width: 400,
   renderTo: Ext.getBody(),
   source: {
       name: "My Object",
       created: Ext.Date.parse('10/15/2006', 'm/d/Y'),
       timeofday: "12:00 PM",
       available: false,
       version: 0.01,
       description: Ext.encode({
           product: 'Clorox',
           tagline: 'The Shinyest White!'            
       }),
       childAccounts:['john','mike']

   },
   customEditors: {
       timeofday: Ext.create('Ext.form.TimeField', {selectOnFocus: true}),
       description: {
           xtype: 'customeditorfield'  
       },
       childAccounts:Ext.create('Ext.form.ComboBox', {store: ['john', 'mike', 'harvey'],multiSelect:true}),
   },
   customRenderers: {
       timeofday: function( v ) {
           return Ext.isDate( v ) ? Ext.Date.format( v, 'g:i A' ) : v;
       }
   },
   propertyNames: {
       name: '(name)',
       created: 'Created Date',
       timeofday: 'Time of Day',
       available: 'Available?',
       version: 'Version',
       description: 'Product Description',
       childAccounts: 'Child Description'
   },
   listeners: {
       beforeedit: function( editor, e, opts ) {
           if( e.record.get( 'name' )=='name' || e.record.get( 'name' )=='version' ) {
               return false;            
           }                
       }            
   }
});

解法:

您的 "childAccounts" 配置不正确。尝试替换:

childAccounts:['john','mike']

与:

childAccounts: 'john, mike'

备注:

使用 ExtJS 4.2 测试。

默认情况下,属性 网格仅支持 "editable" 个值,并且 Sencha 不将数组视为可编辑。如果需要,您可以尝试覆盖它。在Ext.grid.property.Store.getReader中引入了限制,其中有一个函数isEditableValue:

isEditableValue: function(val){
    return Ext.isPrimitive(val) || Ext.isDate(val) || val === null;
}

如果您更改此函数以允许数组,它似乎可以工作,但不提供保证。我使用以下代码进行快速测试:

Ext.define('', {
    override: 'Ext.grid.property.Store', 
    getReader: function() {
        var newReader = !this.reader;
        this.callParent(arguments);
        if(newReader) this.reader.isEditableValue = function(val) {
            return Ext.isPrimitive(val) || Ext.isDate(val) || Ext.isArray(val) || val === null;
        }
        return this.reader;
    }
});

Fiddle(无保修,一如既往)