ExtJS 4.2:在 BoxSelect 上动态添加新选择
ExtJS 4.2: Adding a New Selection on a BoxSelect on the Fly
我有一个表单,其中有一个由我的商店填充的字段:
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']
});
我的商店包含一个简单的商品列表:
{
提供商状态:[{
编号:"EXPIRED",
姓名:"EXPIRED"
}, {
编号:"ERROR",
姓名:"ERROR"
}, {
编号:"FRAUD",
姓名:"FRAUD"
}, {
编号:"PAID",
姓名:"PAID"
}, {
编号:"UNCONFIRMED",
姓名:"UNCONFIRMED"
}]
}
在我的表单中,上面的商店随后由 BoxSelect 填充:
{
xtype: 'boxselect',
name: 'providerstatus',
fieldLabel: oMe.providerstatusField,
width: 468,
store: 'TransactionProviderStatus',
displayField: 'name',
valueField: 'id',
minChars: 2,
typeAhead: true
}
虽然这非常有效,但我还打算在用户在其中键入新值时添加更多项目。请注意,此 BoxSelect 是一个多选。目前,当我在上面输入随机值时,它只是将其清除。
如何设置此特定字段,以便我能够添加更多项目,并将其作为将在提交时传递的数据的一部分包含在内?
你试过forceSelection:false
选择这个框吗?
当 forceSelection 为 false 时,用户可以在键入时创建新记录。这些记录不会添加到组合的商店中。可以通过使用定界符分隔它们来添加多个新值,并且可以使用 createNewOnEnter 和 createNewOnBlur 配置选项进一步配置。
同时检查 createNewOnEnter
和 createNewOnBlur
我有一个表单,其中有一个由我的商店填充的字段:
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']
});
我的商店包含一个简单的商品列表:
{ 提供商状态:[{ 编号:"EXPIRED", 姓名:"EXPIRED" }, { 编号:"ERROR", 姓名:"ERROR" }, { 编号:"FRAUD", 姓名:"FRAUD" }, { 编号:"PAID", 姓名:"PAID" }, { 编号:"UNCONFIRMED", 姓名:"UNCONFIRMED" }] }
在我的表单中,上面的商店随后由 BoxSelect 填充:
{
xtype: 'boxselect',
name: 'providerstatus',
fieldLabel: oMe.providerstatusField,
width: 468,
store: 'TransactionProviderStatus',
displayField: 'name',
valueField: 'id',
minChars: 2,
typeAhead: true
}
虽然这非常有效,但我还打算在用户在其中键入新值时添加更多项目。请注意,此 BoxSelect 是一个多选。目前,当我在上面输入随机值时,它只是将其清除。
如何设置此特定字段,以便我能够添加更多项目,并将其作为将在提交时传递的数据的一部分包含在内?
你试过forceSelection:false
选择这个框吗?
当 forceSelection 为 false 时,用户可以在键入时创建新记录。这些记录不会添加到组合的商店中。可以通过使用定界符分隔它们来添加多个新值,并且可以使用 createNewOnEnter 和 createNewOnBlur 配置选项进一步配置。
同时检查 createNewOnEnter
和 createNewOnBlur