Forms extjs表单面板设置默认值textfield
这似乎是一个微不足道的问题,但是。。。我在一个面板中有一个地址列表,我希望在其中添加地理位置坐标(并在地图上显示),这些坐标在表单面板中呈现,因此,当我在面板中单击感兴趣的地址时,将触发一个onTap,以执行下面给出的onSelectGeolocation,打开在视口中呈现的表单面板,并将任何现有记录添加到关联的表单元素中:Forms extjs表单面板设置默认值textfield,forms,sencha-touch,textfield,default-value,Forms,Sencha Touch,Textfield,Default Value,这似乎是一个微不足道的问题,但是。。。我在一个面板中有一个地址列表,我希望在其中添加地理位置坐标(并在地图上显示),这些坐标在表单面板中呈现,因此,当我在面板中单击感兴趣的地址时,将触发一个onTap,以执行下面给出的onSelectGeolocation,打开在视口中呈现的表单面板,并将任何现有记录添加到关联的表单元素中: onSelectGeolocation: function(view, index, target, record, event) { console.log('S
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渲染为视口的“我的表单”面板是:
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'
}
]
}
});
行为如预期。我将在每个项目的id上使用Ext.getCmp。明白了!“name”和“itemId”的参数相互冲突。将“itemId”替换为“id”,一切都很好。我没有了解全部情况:默认值仅在注释掉“name”参数时显示。但是,这是一个问题,因为我希望该字段自动包含在表单submit()中。这可能是一只虫子吗?(我将在Sencha Touch论坛上发布)在进一步研究的基础上对原始问题进行了更正。