我有一个带有以下配置的标记字段
{
forceSelection: false,
createNewOnBlur: true,
createNewOnEnter: true,
pageSize: true,
minWidth: 340,
// Note that everything is remote
queryMode: 'remote',
remoteFilter: true,
remoteSort: true
}
我想要实现的目标是:
知道如何执行此操作吗? 提前致谢, PsychoKrameur
编辑:即使是为了完美,我找到了实现第一部分的方法。 我重写了以下方法:
我有一个事件 beforecreatedrecord 可以停止执行。 在我的控制器上,我检查记录是否是 phantom ,如果是,我停止执行直到创建记录,然后再次请求setValue。
请参阅我覆盖的部分方法:
setValue: function(value, /* private */add, skipLoad) {
// ...
if (!valueRecord) {
if (me.forceSelection) {
unknownValues.push(record);
}
else {
valueRecord = {};
// OVERRIDE
// remove the set of the id to have the model phantom (in my case valueField was the id)
//valueRecord[me.valueField] = record;
valueRecord[me.displayField] = record;
cls = me.valueStore.getModel();
valueRecord = new cls(valueRecord);
// Send a event that can stop execution
if (me.fireEvent('beforecreaterecord', me, valueRecord, record) === false) {
// if false stop here
return false;
}
}
}
//..
},
doSetValue: function(value /* private for use by addValue */, add) {
//...
// We are allowing added values to create their own records.
// Only if the value is not empty.
if (!record && value[i]) {
dataObj = {};
dataObj[me.displayField] = value[i];
// OVERRIDE
// APPLY THE SAME PRINCIPLE AS ABOVE
// if (me.valueField && me.displayField !== me.valueField) {
// dataObj[me.valueField] = value[i];
// }
record = new Model(dataObj);
if (me.fireEvent('beforecreaterecord', me, record, dataObj) === false) {
// if false stop here
return false;
}
}
}
//...
}