我创建了一个有两列的表单,在我的viewcontroller中,我想访问表单的值。在我的viewcontroller中,我想访问表单的值,不幸的是,我只访问了左边的列。我如何访问右列的值呢?
Ext.define('ocm.view.ocmMask.ModalOverviewOperationsEdit', {
extend: 'Ext.window.Window',
xtype: 'modaloperationedit',
title: 'Einsatz bearbeiten',
frame: true,
resizable: true,
width: 700,
minWidth: 700,
minHeight: 300,
bodyPadding: 0,
layout: 'column',
controller: 'overviewoperations',
defaults: {
layout: 'form',
xtype: 'container',
defaultType: 'textfield',
style: 'width: 50%'
},
items: [{
//I get the Values of this column
xtype: 'form',
items: [
{
xtype: 'datefield',
fieldLabel: BpcCommon.lang.Current.OCM_MASK_DATE,
maxValue: new Date(),
bind: "{operation.ALARMIERUNGSDATUM}",
name: 'ALARMIERUNGSDATUM',
required: true
}]
}, {
//I didn't get this values
items: [
{
xtype: 'combobox',
store: "ocmKeywordStore",
valueField:'ID',
name: "ALLOCATION",
id: "ALLOCATION",
fieldLabel: BpcCommon.lang.Current.OCM_MASK_ALLOCATION,
displayField:'Text',
queryParam: false,
editable: false,
}]
}],
在视图控制器中,我的访问方式如下
Ext.define('ocm.view.ocmMask.OverviewOperationsController', {
extend: 'Ext.app.ViewController',
alias: 'controller.overviewoperations',
updateOperation: function(btn){
var win = btn.up('window'),
getForm = win.down('form');
var values = getForm.getValues();
console.log(values);
}
});
主要的问题是你的第二个字段不在你的表单里面。
现在你有一个 Ext.window.Window
随着 layout
列,其中包含一个带有数据域的表单和一个包含Combobox的容器。
所以你的 getValues
(https:/docs.sencha.comextjs6.0.1classicExt.form.Panel.html#method-getValues。)方法做了正确的事情,给了你所有包含在表单中的字段的值。
我只是做了一个小动作。也许你更想找这样的方法?