medley
7 Sep 2011, 5:22 AM
Hello,
I have a grid and form. When I click on one row of the grid, the form is loaded with the selected record.
1 - When I change the value of one field, I disable the grid (see change event of my controller).
2 - When I click on the button 'Cancel', I reload the form with the selected row of the grid and I enable the grid (function "cancelEditService") . However, after the reload, the event "change" fires and I don't want it to fire.
Ext.define('EPplatosRegistry.controller.Services', {
extend : 'Ext.app.Controller',
...
'serviceedit > textfield': {
change: {
fn: this.textFieldChange,
buffer: 500 // Delay the request by half a second
}
}
});
},
...
cancelEditService : function(button) {
var grid = this.getServiceslist(), record = grid.getSelectionModel().getLastSelected(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'),
editButton = toolbar.getComponent('edit');
var items = form.items;
var i = 0;
for(i = 0; i < items.length; i += 1){
items.getAt(i).setReadOnly(true);
}
form.loadRecord(record);
grid.enable();
editButton.enable(); saveButton.disable(); cancelButton.disable();
},
...
textFieldChange: function(textField, newValue, oldValue, options) {
var grid = this.getServiceslist(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'),
editButton = toolbar.getComponent('edit');
if(textField.name != 'revision') {
saveButton.enable();cancelButton.enable();editButton.disable();
grid.disable();
}
}
});
Thanks for help
Medley
I have a grid and form. When I click on one row of the grid, the form is loaded with the selected record.
1 - When I change the value of one field, I disable the grid (see change event of my controller).
2 - When I click on the button 'Cancel', I reload the form with the selected row of the grid and I enable the grid (function "cancelEditService") . However, after the reload, the event "change" fires and I don't want it to fire.
Ext.define('EPplatosRegistry.controller.Services', {
extend : 'Ext.app.Controller',
...
'serviceedit > textfield': {
change: {
fn: this.textFieldChange,
buffer: 500 // Delay the request by half a second
}
}
});
},
...
cancelEditService : function(button) {
var grid = this.getServiceslist(), record = grid.getSelectionModel().getLastSelected(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'),
editButton = toolbar.getComponent('edit');
var items = form.items;
var i = 0;
for(i = 0; i < items.length; i += 1){
items.getAt(i).setReadOnly(true);
}
form.loadRecord(record);
grid.enable();
editButton.enable(); saveButton.disable(); cancelButton.disable();
},
...
textFieldChange: function(textField, newValue, oldValue, options) {
var grid = this.getServiceslist(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'),
editButton = toolbar.getComponent('edit');
if(textField.name != 'revision') {
saveButton.enable();cancelButton.enable();editButton.disable();
grid.disable();
}
}
});
Thanks for help
Medley