【问题标题】:check the values send by form in extjs检查 extjs 中表单发送的值
【发布时间】:2012-06-01 09:37:13
【问题描述】:

我在 extjs 中使用了一个字段集并想提交值。现在我想用警报检查值,但我不知道我该怎么做。

{
   "xtype": "fieldset",
   "height": 377,
   "id": "configurationDriversConfiguration",
   "width": 648,
   "layout": {
      "type": "auto"
   },
   "collapsible": true,
   "title": "Driver Configuration",
   "items": [
      {
         "xtype": "button",
         "id": "configurationDriversAdd",
         "text": "Add"
      },
      {
         "xtype": "button",
         "id": "configurationDriversDelete",
         "text": "Delete"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversCode",
         "fieldLabel": "Driver Code"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversName",
         "fieldLabel": "Driver Name"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversLicense",
         "fieldLabel": "Driver License nr"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversGivenName",
         "fieldLabel": "Driver Given Name"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversFamilyName",
         "fieldLabel": "Driver Familiy Name"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversPhone",
         "fieldLabel": "Driver Phone Nr"
      },
      {
         "xtype": "textfield",
         "id": "configurationDriversEmail",
         "fieldLabel": "Driver Email"
      },
      {
         "xtype": "combobox",
         "id": "configurationDriversProvider",
         "fieldLabel": "Provider",
         "displayField": "name",
         "store": "comboProviders",
         "valueField": "id"
      },
      {
         "xtype": "textareafield",
         "id": "configurationDriversMemo",
         "fieldLabel": "Memo"
      },
      {
         "xtype": "button",
         "height": 37,
         "id": "configurationDriversSave",
         "text": "Save"
      }
   ]
}

是我的代码。当我单击保存时,我想查看所有值。我使用 Sencha Architect,但找不到处理程序

【问题讨论】:

  • 您到底需要什么?检查什么值?您在寻找某种验证吗?
  • 验证会很好。但是我需要的是,当我按下保存时,它会做一些事情:) 并且要查看它的作用,我想查看提交的值。例如在 configurationDriversName 处填写的内容

标签: forms extjs submit handler sencha-architect


【解决方案1】:

在“保存”按钮定义中添加类似这样的内容:

handler: function(btn) {
   var fieldSet = btn.up('fieldset');
   Ext.Array.each(fieldset.items, function(i) {
       console.log(i.getValue());
   });
}

【讨论】:

  • 我这样做:handler: function(button, event) { var fieldSet = button.up('configurationDriversConfiguration'); Ext.Array.each(fieldSet.items, function(i) { alert(i.getValue()); });但我得到一个 fieldSet 未定义 Ext.Array.each(fieldSet.items, function(i) { error
  • 我认为如果您需要通过 id 查找,您需要在选择器中指定 #my_id。没有任何东西 - 这将是 xtype
  • 来吧,伙计...尝试阅读一些有关如何通过项目数组的文档。我说我的代码不是完美的示例——而是一个前进的方向。
猜你喜欢
  • 2020-01-14
  • 2013-05-21
  • 2016-09-06
  • 1970-01-01
  • 2014-06-04
  • 2017-10-07
  • 2014-02-01
  • 2011-06-04
  • 1970-01-01
相关资源
最近更新 更多