PDA

View Full Version : ExtJs ext-4.2.1.883 RowEditing update button is disabled if allowBlank is set



Bruno0226
5 Mar 2014, 11:59 AM
Hy,
(sorry for my english)
I have a grid + rowEditor , and i have a col allowBlank: false
After open rowediting the update button is initially disabled. If i type any character, the update button is not change to enabled.
i have changed the example ext-4.2.1.883\examples\grid\row-editing.js
By adding a new record with name = empty

tbar: [{
text: 'Add Employee',
iconCls: 'employee-add',
handler : function() {
rowEditing.cancelEdit();

// Create a model instance
var r = Ext.create('Employee', {
name: '',
email: '[email protected]',
start: Ext.Date.clearTime(new Date()),
salary: '500',
active: true
});

store.insert(0, r);
rowEditing.startEdit(0, 0);
}
}

after type any character, the update button reamin in disabled status.
How can I solve this? Thanks.

scottmartin
5 Mar 2014, 1:38 PM
This was corrected in 4.2.2. If you do not have access, you could use the following override:



Ext.define('Ext.grid.override.RowEditor', {
override: 'Ext.grid.RowEditor',

initComponent: function() {
var me = this;

me.callParent(arguments);

me.getForm().on('validitychange', me.onValidityChange, me);
},

onValidityChange: function() {
var me = this,
form = me.getForm(),
valid = form.isValid();

if (me.errorSummary && me.isVisible()) {
me[valid ? 'hideToolTip' : 'showToolTip']();
}
me.updateButton(valid);
me.isValid = valid;
}

});

Bruno0226
6 Mar 2014, 10:08 AM
Thank you! Perfect.

incutonez
17 Dec 2014, 7:07 AM
This fix seems to only work once. If I try to add another record, the button is greyed out, and it never even hits the onValidityChange handler. It seems as if the previous record has set the entire form to valid, so it doesn't care about the next added entry.

incutonez
17 Dec 2014, 7:23 AM
FYI, I think I fixed my above issue. In the same overridden code, I added this:



completeEdit: function() {
var me = this,
form = me.getForm();

if (!form.isValid()) {
return false;
}

form.updateRecord(me.context.record);
me.hide();
form.reset();
return true;
}


The key is that form.reset right before the return.