0

这似乎是一个微不足道的问题,但是......我在面板中有一个地址列表,我希望在表单面板中添加地理位置坐标(并在地图上显示它们),以便当我单击在面板中感兴趣的地址上,触发 onTap 以执行下面给出的 onSelectGeolocation 以打开 ViewPort 中呈现的表单面板并将任何现有记录添加到关联的表单元素:

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 呈现为 ViewPort 的表单面板是:

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

    ]
    }

});
4

1 回答 1

0

行为符合预期。我将在每个项目的 id 上使用 Ext.getCmp。

于 2013-04-10T15:00:34.633 回答