我有一个组合框(例如change owner)。当用户选择combobox的值时,如果用户确定要更改所有者,我将提示用户。如果他点击“是”,我就会更新数据库中的记录。到目前为止,一切都很好。
现在,如果用户选择了一个值并在提示符上单击了'No‘(在从组合框中选择了值之后)。组合将保留新值,而不会将其恢复为旧值。我尝试了setValue/Load等,但没有一个在单击No时设置回旧值。
我的代码如下所示
combo = new Ext.form.ComboBox({
store: storeJson,
xtype: 'combo',
displayField:'name',
valueField: 'id',
mode: 'local',
id: 'privateTo',
name: 'privateTo',
typeAhead: false,
triggerAction: 'all',
lazyRender: true,
editable:false,
listeners: {select: changeOwner}
});
var changeOwner = function(combo, record, index) {
Ext.MessageBox.confirm("Change Owner","Are you sure you want to change owner?",function(btn){
if (btn == "yes") {
Ext.Ajax.request({
url: 'somUrl',
method: 'PATCH',
success: function(result, request) {
msg('Owner changed', 'Owner changed');
},
failure: function(result, request) {
Ext.MessageBox.alert('Error', "Unable to change owner");
Ext.getCmp("customizationGrid").getStore().reload();
}
});
} else {
var d = Ext.getCmp('customizationGrid').getSelectionModel().selection;
var rec = combo.store.getById(d.record.json.privateTo);
Ext.getCmp("privateTo").setValue(rec.data.name);
}
});
}发布于 2015-09-07 14:52:42
只需删除else { ... }块,它应该会处理NO。:-)
发布于 2012-08-16 09:46:07
您的组合的最后一个选定值已经存在于选择处理程序中。
您可以简单地这样做:
..。
} else {
combo.setValue(combo.startValue);
}https://stackoverflow.com/questions/11905534
复制相似问题