FormPanel.getForm().isValid() only apply elements in <Items> ?

Page 1 of 2 12 LastLast
  1. #1

    FormPanel.getForm().isValid() only apply elements in <Items> ?

    Hi..

    I put a panel in <Items> then put some htmls & ext.net controls into <Content> and everything is right (even checkedItems of radiogroup).

    But it seems not go into content of panel when I use #{Formpanel11}.getForm().isValid() ?

    the validation result is always true.

    Dose it not support this usage ? just valiid element in <Items> ?

    the sample code as following:

    ASPX
    <%@ Page Language="C#" CodeFile="OnlyTest.aspx.cs" Inherits="OnlyTest" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form id="testForm" runat="server">
        <div>
            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
       <ext:FormPanel ID="FormPanel1" runat="server" Title="" Border="false" HideBorders="true" MonitorValid="True" BodyBorder="False">
           <Items>
            <ext:Panel ID="Panel1" runat="server" Border="false" HideBorders="true" IsFormField="true">
                <Content>
                    <ext:ComboBox ID="ComboBox1" runat="server" AllowBlank="false">
                        <DirectEvents>
                            <Select OnEvent="ComboBox1_OnSelected">
                                <EventMask ShowMask="true" MinDelay="100" />
                            </Select>
                        </DirectEvents>
                    </ext:ComboBox>
                    <ext:RadioGroup ID="RadioGroup1" runat="server" AllowBlank="false">
                        <DirectEvents>
                            <Change OnEvent="RadioGroup1_OnChanged">
                                <EventMask ShowMask="true" MinDelay="100" />
                            </Change>
                        </DirectEvents>
                    </ext:RadioGroup>    
                    <ext:Label ID="Label1" runat="server"></ext:Label>
    
                    <ext:Button ID="btnSubmit" runat="server" FormBind="true" CausesValidation="true" Text="Submit Test" OnClientClick="alert(#{FormPanel1}.getForm().isValid())"></ext:Button>   
               </Content>
           </ext:Panel>
           </Items> 
        </ext:FormPanel>
        </div>
        </form>
    </body>
    </html>
    C# Code:
    public partial class OnlyTest : System.Web.UI.Page
    {
        private IList<TestDataItem> DemoSource { get; set; }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            DemoSource = getDemoData();
            initFormElemet();
        }
    
    
        private void initFormElemet()
        {
    
            foreach (TestDataItem item in DemoSource)
            {
    
                ComboBox1.Items.Add(new Ext.Net.ListItem(item.ItemText, item.ItemValue));
    
                Ext.Net.Radio radioItem = new Ext.Net.Radio(new Ext.Net.Radio.Config()
                {
                    Checked = false
                });
    
                radioItem.InputValue = item.ItemValue;
                radioItem.BoxLabel = item.ItemText;
                RadioGroup1.Items.Add(radioItem);
    
            }
    
            ComboBox1.FieldLabel = BasePage.GetTitle("BtnSelectProj");
            ComboBox1.AllowBlank = false;
            RadioGroup1.ColumnsNumber = 1;
            RadioGroup1.Vertical = true;
            RadioGroup1.FieldLabel = BasePage.GetTitle("BtnSelProj");
        }
    
        protected void ComboBox1_OnSelected(object sender, Ext.Net.DirectEventArgs args)
        {
            Label1.Text = ComboBox1.SelectedIndex.ToString();
    
            if (ComboBox1.SelectedIndex >= 0)
            {
                Label1.Text = ComboBox1.SelectedItem.Text;
            }
        }
    
        protected void RadioGroup1_OnChanged(object sender, Ext.Net.DirectEventArgs args)
        {
            Label1.Text = RadioGroup1.CheckedItems.Count.ToString();
    
            if (RadioGroup1.CheckedItems.Count > 0)
            {
                Label1.Text = RadioGroup1.CheckedItems[0].BoxLabel;
            }
        }
    
        // for test
        private IList<TestDataItem> getDemoData()
        {
    
            IList<TestDataItem> demoDataList = new List<TestDataItem>();
    
            demoDataList.Add(new TestDataItem("XXXX", "0"));
            demoDataList.Add(new TestDataItem("YYYY", "3"));
            demoDataList.Add(new TestDataItem("ZZZZ", "4"));
    
            return demoDataList;
        }
    
    }
    
    public class TestDataItem
    {
        public string ItemValue { get; set; }
        public string ItemText { get; set; }
    
        public TestDataItem(string text, string value)
        {
            ItemValue = value;
            ItemText = text;
        }
    }
  2. #2
    Hi,

    Yes, <Content> breaks validation logic.

    <Content> renders just as html.
  3. #3
    Hi,

    Thanks for your reply.

    I will write some javascript to validate the component in context.
  4. #4
    You can be interested in this code:
    http://forums.ext.net/showthread.php...ll=1#post56732
  5. #5
    Hi,

    Thanks for your reply.

    I share my way to validate, if are there any better solutions, please tell me . thanks again.

    <script>
     function myValidate() { 
              var inValidformElements = Ext.ComponentMgr.all.filterBy(
                        function (o, k) { 
                             return !(o.isFormField && o.isValid()); 
               }); 
              if (inValidformElements.getCount() > 0) { 
                       return false; 
              } 
              else { 
                      return true; 
              } 
      }
    </script>
  6. #6
    Looks good. Maybe replace
    if (inValidformElements.getCount() > 0) {     return false; 
    } else {
       return true; 
    }
    with
    return !(inValidformElements.getCount() > 0)
    By the way.
    I put a panel in <Items> then put some htmls & ext.net controls into <Content>
    Are you sure that you can't avoid it? Do you need to validate non Ext.Net controls?
    Last edited by Daniil; Nov 19, 2015 at 1:18 PM.
  7. #7
    Thanks.

    We assume only Ext.Net controls and a lot of html code,

    because we believe Ext.Net controls could be repleaced with all of ASP.NET controls. :)
  8. #8
    BTW...

    I still cannot find a way to simulate "Validation Group" of ASP.NET validation.

    In fact, I had tried to use panel for grouping some controls, like a group.

    Unforturnally, cotnrols which put in Context just render as HTML,

    it means we cannot find parent by using Ext.Component.findParentByType, they never belong in <Items> of Panel.

    So... we hope the ap never needs to use something like "Validation Group".
  9. #9
    Quote Originally Posted by YuanChien View Post
    We assume only Ext.Net controls and a lot of html code
    Example 1
    I'd suggest you something like this:
    <ext:Container runat="server">
        <Items>
            <ext:Container runat="server">
                <Content>
                    html
                </Content>
            </ext:Container>
            <ext:FormPanel runat="server">
                <Items>
                    Ext.Net controls
                </Items>
            </ext:FormPanel>
        </Items>
    /ext:Container>
    or

    Example 2
    <ext:FormPanel runat="server">
        <Items>
            <ext:Container runat="server">
                <Content>
                    html
                </Content>
            </ext:Container>
            Ext.Net controls for validation
        </Items>
    </ext:FormPanel>
    Quote Originally Posted by YuanChien View Post
    because we believe Ext.Net controls could be repleaced with all of ASP.NET controls. :)
    Not sure what you mean, please clarify.
  10. #10
    Quote Originally Posted by YuanChien View Post
    I still cannot find a way to simulate "Validation Group" of ASP.NET validation.
    Maybe something like this:
    https://examples1.ext.net/#/Toolbar/StatusBar/Advanced/
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: May 20, 2010, 7:57 AM
  2. [CLOSED] 2nd Tab Formpanel IsValid Error
    By CMA in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 02, 2010, 11:59 AM
  3. [CLOSED] FormPanel Validation with isValid
    By rcaunt in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 05, 2010, 1:07 PM
  4. [CLOSED] Form Validation getForm().isValid();
    By CMA in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Aug 24, 2009, 10:45 AM
  5. Replies: 0
    Last Post: Jun 08, 2009, 6:09 AM

Tags for this Thread

Posting Permissions