[CLOSED] How to deal with multiple validation groups?

  1. #1

    [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 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]
  2. #2
    Hi @exe,

    ValidationGroup is a native ASP.NET property and used for server side validation. Ext.NET doesn't use it for client side validation.

    So I tried to validate the fields manually
    Yes, it is a way to go.

    But I couldn't find the ValidationGroup property of the field.
    ValidationGroup is not rendered to client (since it is used by ASP.NET for server side validation).

    Please use CustomConfig.
    <ext:TextField ...>
        <CustomConfig>
            <ext:ConfigItem Name="validationGroup" Value="vg1" Mode="Value" />
        </CustomConfig>
    </ext:TextField>
  3. #3
    Ok, thanks!

Similar Threads

  1. Replies: 3
    Last Post: Feb 22, 2015, 3:29 PM
  2. [CLOSED] Drag and Drop Multiple Groups
    By ATLAS in forum 2.x Legacy Premium Help
    Replies: 21
    Last Post: Sep 26, 2013, 7:22 AM
  3. [CLOSED] Drag and Drop with multiple Groups
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 31, 2012, 2:50 PM
  4. [CLOSED] Validation Before Call to Handler with Multiple Forms
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 12, 2012, 3:43 PM
  5. Replies: 3
    Last Post: Sep 30, 2010, 9:13 PM

Tags for this Thread

Posting Permissions