对于组合框字段,在编辑窗口中,我需要使该字段仅向上或向下更改一个值,例如在创建新记录或对其进行编辑时。
....
{
xtype: 'combobox',
name: 'status',
fieldLabel: 'Status',
displayField: 'name',
valueField: 'id',
queryMode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: ['id','name'],
data: [[1, 'Новая'], [2, 'В работе'], [3, 'В ожидании'], [4, 'Закрытая'], [5, 'Архивная']]
}),
listeners: {
'select': function (combo, record) {
index = record.internalId;
filterCombo(combo, index);
},
'render': function (combo) {
//index = combo.getSelection().internalId;
//filterCombo(combo, index);
}
}
},
....
我使用select和render事件来做到这一点。 filterCombo函数如下所示:
function filterCombo(combobox, index) {
store = combobox.getStore();
store.clearFilter();
store.filterBy(
function(record) {
if ((record.internalId == index - 1) || (record.internalId == index) || (record.internalId == index + 1)) {
return true;
} else {
return false;
}
}
);
}
combo.getSelection () (ReferenceError: index is not defined)
中存在错误。为什么?filterCombo
函数的最正确之处就是不要将其留在App.view.TestEdit
视图中
示例Fiddle 谢谢