Nov 18, 2015, 8:56 PM
[CLOSED] How to deal with multiple validation groups?
Hi,
how should I set up my page to be able to deal with multiple validation groups?
This is a very simple example of two fields with different validation groups. I need to validate only one group, before saving the form. I know, there is a
Please let me know, what is the preferred approach to this problem.
Thank you!
how should I set up my page to be able to deal with multiple validation groups?
This is a very simple example of two fields with different validation groups. I need to validate only one group, before saving the form. I know, there is a
Buttons
collection in the FormPanel
, and tried to use FormBind
property along with ValidationGroup
, but the later seems to be ignored.<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}
}
private void Save(object sender, DirectEventArgs e)
{
throw new NotImplementedException();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<script type="text/javascript">
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:FormPanel ID="FormPanel1" runat="server" Frame="True" MinHeight="200" Border="False" Layout="Form" BodyPadding="10" ButtonAlign="Left" AutoScroll="True" >
<Items>
<ext:TextField runat="server" ID="tf1" FieldLabel="Field1" ValidationGroup="vg1" AllowBlank="False"></ext:TextField>
<ext:TextField runat="server" ID="tf2" FieldLabel="Field2" ValidationGroup="vg2" AllowBlank="False"></ext:TextField>
</Items>
</ext:FormPanel>
<ext:Panel runat="server">
<Items>
<ext:Button runat="server" ID="btSave" Text="Validate only vg1">
<DirectEvents>
<Click OnEvent="Save" Before="return #{FormPanel}.validate();"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
</body>
</html>
So I tried to validate the fields manually, like this: NS.getInvalidFields = function(form, validationGroup) {
var invalidFields = [];
Ext.suspendLayouts();
form.getForm().getFields().filterBy(function (field) {
if (field.validate()) return;
invalidFields.push(field);
});
Ext.resumeLayouts(true);
return invalidFields;
}
But I couldn't find the ValidationGroup
property of the field.Please let me know, what is the preferred approach to this problem.
Thank you!
Last edited by Daniil; Nov 21, 2015 at 7:37 AM.
Reason: [CLOSED]