PDA

View Full Version : Form Validation and RowEditor Cancel problem



alexaung
9 Nov 2010, 3:28 AM
Hi All,

I have a form with RowEditor grid. There are two Combo column in RowEditor grid. Both of the Combo are required.

All of my validation are working fine. But today, user found out that if they click Add button, the roweditor occur and showing 2 combo box. so QuickTip show both column is required since I did not choose any combo yet. so that my update button on roweditor is disabled. And then click "Cancel" button. so far so good. I just save the record in store because my form have other few fields. Then I entered all required fields and click "Submit". Then myform.isValid() return false and two undefined field is required. Please let me know how to destroy these unwanted Combo box.

here is my roweditor canceledit event


editor.on({
scope: this,
beforeedit: function (roweditor, rowIndex) {
var record = userRolesStore.getAt(rowIndex);
if (record.get('IsDefault') == 1) { // replace with your condition
Ext.MessageBox.show({
title: 'ERROR',
msg: "Can't not edit default user role.",
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
return false;
}
},
canceledit: function (roweditor, iSCancel) {
editor.stopEditing();
var record = userRolesStore.getAt(roweditor.rowIndex);
if (!Ext.isDefined(record.get('RoleId')) && !Ext.isDefined(record.get('BusinessUnitId')))
userRolesStore.removeAt(roweditor.rowIndex);
gridRole.getView().refresh();
},
afteredit: function (roweditor, changes, record, rowIndex) {
//your save logic here - might look something like this:
}
}); // End Configuration


my submit button event


if (masterForm.getForm().isValid()) {
//do something
}
else
{
//show message
}

bookyjhonny
29 Dec 2011, 7:20 PM
BookGrill = free technology books http://goo.gl/kxhMD Get free books