我有一個組合框(例如更改所有者)。當用戶選擇組合框的值時,如果他確定要更換所有者,我會提示用戶。如果他點擊「是」,我更新數據庫中的記錄。所有工作都很好,直到這一點。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);
}
});
}