2013-04-07 153 views
0

這似乎是一個微不足道的問題,但是...我有一個地址列表,我希望在其中添加地理座標(並在地圖上顯示它們)在面板中單擊感興趣的地址時,會觸發onTap來執行下面給出的onSelectGeolocation,以打開在ViewPort中呈現的表單面板並將任何現有記錄添加到關聯的表單元素中:extjs表單面板集默認值textfield

onSelectGeolocation: function(view, index, target, record, event) { 
    console.log('Selected a Geolocation from the list'); 
    var geolocationForm = Ext.Viewport.down('geolocationEdit'); 


    if(!geolocationForm){ 
     geolocationForm = Ext.widget('geolocationEdit'); 
    }  
    geolocationForm.setRecord(record); 
    geolocationForm.showBy(target); 
} 

然而使用該方法setRecord寫在我的商店任何現有記錄到表單元素,該生產線,正在阻止的默認值在我的形式面板下方從獲取寫入到所期望的形式的元素。當我評論這一點時,一切都很好。問題是我需要獲取存儲在我商店中的記錄,例如地址,以顯示在我的表單中。我怎樣才能做到這一點,並將默認值寫入我的表單中的文本字段元素?這是通過渲染的onTap作爲視口

我的形式面板:不出所料

Ext.define('EvaluateIt.view.GeolocationEdit', { 
    extend: 'Ext.form.Panel', 
    alias : 'widget.geolocationEdit', 
    requires: [ 
     'Ext.form.Panel', 
     'Ext.form.FieldSet', 
     'Ext.field.Number', 
     'Ext.field.DatePicker', 
     'Ext.field.Select', 
     'Ext.field.Hidden' 

    ], 
    config: { 

    // We give it a left and top property to make it floating by default 
    left: 0, 
    top: 0, 

    // Make it modal so you can click the mask to hide the overlay 
    modal: true, 
    hideOnMaskTap: true, 

    // Set the width and height of the panel 
    width: 400, 
    height: 330, 
    scrollable: true, 
    layout: { 
     type: 'vbox' 
    }, 
    defaults: { 
     margin: '0 0 5 0', 
     labelWidth: '40%', 
     labelWrap: true 
    }, 
    items: [ 
     { 
      xtype: 'datepickerfield', 
      destroyPickerOnHide: true, 
      name : 'datOfEvaluatione', 
      label: 'Date of evaluation', 
      value: new Date(), 
      picker: { 
       yearFrom: 1990 
      } 
     }, 
     { 
      xtype: 'textfield', 
      name: 'address', 
      label: 'Address', 
      itemId: 'address' 
     }, 
     { 
      xtype: 'textfield', 
      name: 'latitude', 
      label: 'Latitude', 
      itemId: 'latitude', 
      value: sessionStorage.latitude,    
     }, 
    /* { 
      xtype: 'textfield', 
      name: 'longitude', 
      label: 'Longitude', 
      itemId: 'longitude', 
      value: sessionStorage.longitude 
     }, 
     { 
      xtype: 'textfield', 
      name: 'accuracy', 
      label: 'Accuracy', 
      itemId: 'accuracy', 
      value: sessionStorage.accuracy 
     },*/ 
     { 
      xtype: 'button', 
      itemId: 'save', 
      text: 'Save' 
     } 

    ] 
    } 

}); 
+0

Got it! 「name」和「itemId」的參數相互衝突。用「id」代替「itemId」,一切都很好。 – 2013-04-08 02:15:17

+0

我沒有全部內容:只有當「name」參數被註釋掉時,纔會顯示默認值。但是,這是一個問題,因爲我希望該字段自動包含在表單submit()中。這可能是一個錯誤嗎? (我會在Sencha Touch論壇上發佈這個) – 2013-04-08 02:26:22

+0

根據進一步的研究對原始問題作出更正。 – 2013-04-09 01:42:59

回答

0

行爲。我將在每個項目的ID上使用Ext.getCmp。