[CLOSED] Validation

  1. #1

    [CLOSED] Validation

    I have a grid with a combo editor and a RowEditing plugin. The combo allows type-ahead. Now I am trying to validate my entry. When I just type in some letters and tab without actually selecting anything from the drop-down, the new value is that text, and not the value associated in the store (which, since it doesn't exist should be null or 0 - I would think). Also, because I am in a grid and using an "Add" button, I have inserted to the grid and have to use a cancel edit function to remove that insert if the row editor is cancelled. So, my question is how do I validate my combo and stop any other eventes without raising the cancel event on my RowEditing plug-in?
    Last edited by Daniil; Jun 20, 2012 at 11:04 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I would try to use the ComboBox Validator.
    http://docs.sencha.com/ext-js/4-1/#!...-cfg-validator

    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.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "item1" },
                    new object[] { "2", "item2" },
                    new object[] { "3", "item3" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            var myValidator = function (value) {
                var valid = true;
                
                if (value !== "item2") {
                    valid = "Must be 'item2'";
                }
    
                return valid;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:ComboBox ID="ComboBox1" runat="server">
                <Validator Fn="myValidator" />
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
            </ext:ComboBox>
        </form>
    </body>
    </html>

Similar Threads

  1. Client Side Validation and Validation Status
    By speddi in forum 1.x Help
    Replies: 8
    Last Post: Nov 03, 2011, 11:24 AM
  2. Replies: 3
    Last Post: Jul 11, 2011, 9:43 AM
  3. [CLOSED] Validation
    By pdcase in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 06, 2010, 8:23 PM
  4. [CLOSED] validation
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 09, 2009, 10:00 AM
  5. [CLOSED] validation
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 15, 2009, 8:53 AM

Tags for this Thread

Posting Permissions