[CLOSED] RowEditor Validation

  1. #1

    [CLOSED] RowEditor Validation

    Hi,

    When opening a row editor with fields that have AllowBlank="false" set on them, the errors appear immediately before any change has been made (and therefore turn all the blank fields red).

    Is there a way to stop this from happening (i.e. only validate those fields once they have been changed or on clicking "Update")?

    Thanks
    Last edited by Daniil; Jul 25, 2011 at 8:55 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please see the example.

    The key points are:

    1. MonitorValid="false" for the RowEditor;
    2. The code of the AfterRender listener.

    Example

    <%@ 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)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "", "test12", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var onAfterRender = function () {
                var re = RowEditor1;
    
                re.on("afterrender", function () {
                    clearInvalid(this);
                    this.on("show", function () {
                        clearInvalid(this);
                    });
                },
                re,
                {
                    delay : 10
                });
            };
            
            var clearInvalid = function (re) {
                re.items.each(function(f) {
                    f.clearInvalid && f.clearInvalid();
                });
            };
        </script>
    
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" Height="300">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                    <ext:RecordField Name="test3" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Test2" DataIndex="test2" />
                        <ext:Column Header="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:RowEditor ID="RowEditor1" runat="server" MonitorValid="false" />
                </Plugins>
                <Listeners>
                    <AfterRender Fn="onAfterRender" />
                </Listeners>
            </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Remote Validation using RowEditor
    By mait_k in forum 1.x Help
    Replies: 1
    Last Post: Dec 20, 2011, 4:24 PM
  2. RowEditor startEdit and validation
    By ralex in forum 1.x Help
    Replies: 11
    Last Post: Nov 23, 2011, 9:03 PM
  3. RowEditor validation
    By reezvi in forum 1.x Help
    Replies: 0
    Last Post: Aug 12, 2011, 6:36 PM
  4. [CLOSED] RowEditor & Form Validation
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 22, 2011, 9:45 AM
  5. [CLOSED] [1.0] RowEditor validation tooltip obstructing editing
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 09, 2010, 8:04 AM

Tags for this Thread

Posting Permissions