我有一个组合框(例如更改所有者)。当用户选择组合框的值时,如果他确定要更换所有者,我会提示用户。如果他点击“是”,我更新数据库中的记录。所有工作都很好,直到这一点。Extjs ComboBox setValue
现在,如果用户选择一个值并在提示时(从组合中选择值之后)点击“否”。组合保留新值,并且不会将其恢复到旧值。我试过的setValue /负载等,但没有一个是在
号设置回原来的值上点击我的代码看起来像这样
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);
}
});
}