Skip to content
Snippets Groups Projects
Commit 41e7598d authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Modified to recuperate the value of combobox when running with field set.

parent ea2aeb23
No related branches found
No related tags found
No related merge requests found
......@@ -76,29 +76,27 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
// Add a listener to hide the window, clear the form
// when the transaction with the database is successful
this.grid.store.on("save", this.endEdit, this);
// HACK: In version 3.2.1 the data in the record are lost somewhere
// As a consequence, the values appearing in the grid after an
// update are empty. This fix correct this issue.
this.grid.store.on("update", function(store, rec, op){
if(op == Ext.data.Record.COMMIT && Ext.version >= '3.2.1'){
var fields = this.formPanel.getForm().items;
var values = this.formPanel.getForm().getFieldValues(true);
var values = this.formPanel.getForm().getValues();
for(item in values){
rec.data[item] = values[item];
}
for (key in fields.map){
var combo = fields.map[key];
if (combo.xtype== 'xcombobox'){
var cbrec = combo.findRecord(combo.valueField, combo.getValue());
rec.data[combo.displayField] = cbrec.get(combo.displayField);
}
var combos = this.findByType('xcombobox');
for (var i = 0; i < combos.length; i++){
var combo = combos[i];
var cbrec = combo.findRecord(combo.valueField, combo.getValue());
rec.data[combo.displayField] = cbrec.get(combo.displayField);
}
}
}, this);
}, this);
},
/**
......@@ -109,7 +107,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
// Returns true if client-side validation on the form is successful.
if(! this.formPanel.getForm().isValid()){
Ext.Msg.alert('Error', 'Fields in the form are not valid !');
Ext.Msg.alert('Error', 'Few fields in the form are not valid !');
return;
}
......@@ -137,7 +135,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
// Returns true if client-side validation on the form is successful.
if(! this.formPanel.getForm().isValid()){
Ext.Msg.alert('Error', 'Fields in the form are not valid !');
Ext.Msg.alert('Error', 'Few fields in the form are not valid !');
return;
}
......@@ -290,24 +288,23 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
*/
updateRecord: function(record){
var fields = this.formPanel.getForm().items;
var values = this.formPanel.getForm().getFieldValues(true);
// Recuperate all values from the form
var values = this.formPanel.getForm().getValues();
for(item in values){
record.set(item, values[item]);
}
// For foreign key, the record display in the grid contains the
// valueField as well as the displayField.
// Previous action update the former but note the later.
// the next line retrieve the displayField
for (key in fields.map){
var combo = fields.map[key];
if (combo.xtype== 'xcombobox'){
var rec = combo.findRecord(combo.valueField, combo.getValue());
record.set(combo.displayField, rec.get(combo.displayField));
}
// Previous action update the vlueField but note the display field.
// the next line append the displayField
var combos = this.findByType('xcombobox');
for (var i = 0; i < combos.length; i++){
var combo = combos[i];
var rec = combo.findRecord(combo.valueField, combo.getValue());
record.set(combo.displayField, rec.get(combo.displayField));
}
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment