extjs表单面板设置默认值textfield

问题描述 投票:0回答:1

这似乎是一个微不足道的问题,但是...我在面板中有一个地址列表,我希望在表单面板中添加地理位置坐标(以及在地图上显示它们),这样当我点击时在面板中感兴趣的地址上,触发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方法将我的商店中的任何现有记录写入表单元素的行阻止了下面的表单面板中的默认值被写入所需的表单元素。当我发表评论时,一切都很好。问题是我需要抓住我商店中存在的那些记录,例如地址,以便在我的表单中显示。我该怎么做并将默认值写入我的表单中的textfield元素?

我通过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'
        }

    ]
    }

});
forms sencha-touch textfield default-value
1个回答
0
投票

行为与预期一致。我会在每个项目的id上使用Ext.getCmp。

© www.soinside.com 2019 - 2024. All rights reserved.