2011-08-30 38 views
1

我試圖從組合中選擇的記錄加載表格。從組合加載表格

商店正確加載和組合填充,但是,當我從組合中選擇一個值時,表單字段保持空。

任何幫助將不勝感激。

這是代碼:

型號:

Ext.define('AA.model.proc.Process', { 
    extend: 'Ext.data.Model', 
    fields: [ 
    { name: 'name', type: 'string' }, 
    { name: 'owner', type: 'string' }, 
    { name: 'mail_dest', type: 'string' } 
    ], 
    proxy: { 
    type: 'rest', 
    url : 'data/camp.json', 
    reader: { 
     type: 'json', 
     root: 'camp', 
     totalProperty: 'count' 
    } 
} 
}); 

商店:

Ext.define('AA.store.proc.Process', { 
    extend: 'Ext.data.Store', 
    model: 'AA.model.proc.Process', 
    requires: 'AA.model.proc.Process' 
}); 

類別:

Ext.define('AA.view.proc.IM', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.im', 
    title: 'IM', 
    layout: 'fit', 
    height: 500, 
    width: 400, 
    autoShow: true, 
    plain: true, 
    modal: true, 
    headerPosition: 'right', 
    closable: false, 
    initComponent: function() { 
     this.items = [{ 
      xtype: 'form', 
      fileUpload: true, 
      width: 550, 
      autoHeight: true, 
      border: false, 
      bodyStyle: 'padding:5px 5px 0', 
      frame: true, 
      labelWidth: 100, 
      defaults: { 
       anchor: '95%', 
       allowBlank: false, 
       msgTarget: 'side' 
      }, 
      items: [{ 
       xtype: 'combo', 
       name: 'name', 
       store: 'procstore', 
       fieldLabel: 'Name', 
       valueField: 'name', 
       displayField: 'name', 
       width: 150, 
       allowBlank: true, 
       listeners: { 
        scope: this, 
         'select': this.loadForm 
       } 
      }, { 
       xtype: 'textfield', 
       fieldLabel: 'Name', 
       name: 'name' 
      }, { 
       xtype: 'textfield', 
       fieldLabel: 'Owner', 
       name: 'owner' 
      }, { 
       xtype: 'textfield', 
       fieldLabel: 'E-mail owner', 
       name: 'mail_dest' 
      }] 
     }]; 
     this.buttons = [{ 
      text: 'Save', 
      action: 'save' 
     }, { 
      text: 'Cancel', 
      scope: this, 
      handler: this.close 
     }]; 
     this.callParent(arguments); 
    }, 
    loadForm: function (field, record, option) { 
     console.log(record) 
     // firebug returns 
     // $className "AA.model.proc.Process" 
     // $alternateClassName  "Ext.data.Record" 
     console.log(this.down('form')) 
     // firebug returns the right form panel 
     this.down('form').loadRecord(record); 
    } 
}); 

回答

0

這是從documentationselect事件:

選擇(Ext.form.field.ComboBox組合,陣列記錄,對象eOpts)

注意,第二個參數是一個數組。但在你的例子中,第二個參數是Ext.data.Record。您將數組視爲記錄。修改您的loadForm以使其處理記錄數組:

loadForm: function (field,records,option) { 
    this.down('form').loadRecord(records[0]); 
} 

P.S.順便說一句,你有兩個字段name: 'name'