【问题标题】:ExtJS 4.2: Adding a New Selection on a BoxSelect on the FlyExtJS 4.2:在 BoxSelect 上动态添加新选择
【发布时间】:2016-08-26 23:42:32
【问题描述】:

我有一个表单,其中有一个由我的商店填充的字段:

Ext.define('EcommBackoffice.store.TransactionProviderStatus', {
  extend: 'Ext.data.Store',
  autoLoad: true,
  proxy: {
    type: 'ajax',
    url: 'resources/data/providerstatus.json',
    reader: {
      type: 'json',
      root: 'providerstatus'
    }
  },
  fields: ['id', 'name']

});

我的商店包含一个简单的商品列表:

{ 提供者状态:[{ id: "过期", 名称:“过期” }, { id:“错误”, 名称:“错误” }, { id:“欺诈”, 名称:“欺诈” }, { id: "付费", 名称:“付费” }, { id: "未确认", 名称:“未确认” }] }

在我的表单中,上面的存储然后由 BoxSelect 填充:

{
  xtype: 'boxselect',
  name: 'providerstatus',
  fieldLabel: oMe.providerstatusField,
  width: 468,
  store: 'TransactionProviderStatus',
  displayField: 'name',
  valueField: 'id',
  minChars: 2,
  typeAhead: true
}

虽然这很有效,但我还打算在用户在其中键入新值时添加更多项目。请注意,此 BoxSelect 是多选。目前,当我在其上输入随机值时,它只会将其清除。

如何设置此特定字段,以便能够添加更多项目,并将其作为提交时传递的数据的一部分?

【问题讨论】:

    标签: extjs multi-select


    【解决方案1】:

    你试过forceSelection:false这个boxselect吗?

    当 forceSelection 为 false 时,用户可以在键入时创建新记录。这些记录不会添加到组合的存储中。多个新值可以通过用分隔符分隔来添加,并且可以使用 createNewOnEnter 和 createNewOnBlur 配置选项进一步配置。

    同时检查createNewOnEntercreateNewOnBlur

    Create new on Enter for Box Select

    【讨论】:

    • 我添加了createNewOnEntercreateNewOnBlur,就这样。最初尝试了前者,但它没有做任何事情。同时设置forceSelection: false。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    相关资源
    最近更新 更多