[CLOSED] Issues related to custom control

  1. #1

    [CLOSED] Issues related to custom control

    HI Daniil,

    I have a custom control extending the formpanel. I am having two issues.

    1. I want to control the "allowblank" properties for the controls within the custom control by exposing a property (IsMandatory in below code). How to do this? The same behaviour is required for visible and readonly properties.

    2. When i add the same control twice, only one control is displayed. Please advise.

    Custom Control
     public class NxtDecimalNumberRange : NxtFormPanel
        {
            ResourcePlaceHolder decimalrangeholder = new ResourcePlaceHolder();
            NxtNumberField FromNumber = new NxtNumberField();
            NxtNumberField ToNumber = new NxtNumberField();
    
            public override string XType { get { return "NxtDecimalNumberRange"; } }
    
          
            public NxtDecimalNumberRange()
            {
    
                FromNumber.ID = "FromNumber";
                FromNumber.Vtype = "decimalnumberrange";
                FromNumber.Note = "From (number)";
                FromNumber.Width = 100;
                //FromNumber.AllowBlank = false;
                FromNumber.AllowDecimals = true;
                FromNumber.AllowNegative = false;
                FromNumber.DecimalPrecision = 4;
                FromNumber.DecimalSeparator = ",";
                //FromNumber.IndicatorIcon = Icon.BulletRed;
    
                ConfigItem FromNumberConfig = new ConfigItem();
                FromNumberConfig.Name = "endNumberField";
                FromNumberConfig.Value = "#{ToNumber}";
                FromNumberConfig.Mode = ParameterMode.Value;
                FromNumber.CustomConfig.Add(FromNumberConfig);
    
                ToNumber.ID = "ToNumber";
                ToNumber.Vtype = "decimalnumberrange";
                ToNumber.Note = "To (number)";
                ToNumber.Width = 100;
                // ToNumber.AllowBlank = false;
                ToNumber.AllowDecimals = true;
                ToNumber.AllowNegative = false;
                ToNumber.DecimalPrecision = 4;
                ToNumber.DecimalSeparator = ",";
                //ToNumber.IndicatorIcon = Icon.BulletRed;
    
                ConfigItem ToNumberConfig = new ConfigItem();
                ToNumberConfig.Name = "startNumberField";
                ToNumberConfig.Value = "#{FromNumber}";
                ToNumberConfig.Mode = ParameterMode.Value;
                ToNumber.CustomConfig.Add(ToNumberConfig);
    
                Parameter margin = new Parameter();
                margin.Name = "margins";
                margin.Value = "0 7 0 0";
                margin.Mode = ParameterMode.Value;
                this.Defaults.Add(margin);
                this.Layout = "HBoxLayout";
                HBoxLayoutConfig config = new HBoxLayoutConfig();
                config.Pack = BoxPack.Start;
                this.LayoutConfig.Add(config);
                this.Items.Add(FromNumber);
                this.Items.Add(ToNumber);
            }
                
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                this.FieldLabel = LocalizationManager.GetCultureSpecificValue(this.GetType().Name + "." + this.GetType().Name);
                
            }
    
            public bool IsVisible
            {
                get { return (ToNumber.Visible && FromNumber.Visible); }
                set
                {
                    ToNumber.Visible = value;
                    FromNumber.Visible = value;
                }
            }
    
            public bool IsMandatory
            {
                get { return (this.ToNumber.AllowBlank && this.FromNumber.AllowBlank); }
                set
                {
                    if (value)
                    { this.ToNumber.IndicatorIcon = Icon.BulletRed; }
    
                    this.ToNumber.AllowBlank = !value;
                    this.FromNumber.AllowBlank = !value;
                }
            }
    
            public bool IsReadOnly
            {
                get { return (ToNumber.Disabled && FromNumber.Disabled); }
                set
                {
                    ToNumber.Disabled = value;
                    FromNumber.Disabled = value;
                }
            }
    
    C# code
    NxtDecimalNumberRange decimalnumberrange = new NxtDecimalNumberRange();
                                decimalnumberrange.IsMandatory = true;
                                decimalnumberrange.IsVisible = true;
                                decimalnumberrange.IsReadOnly = true;
                                script +=  decimalnumberrange.ToScript(RenderMode.AddTo, containerPanel);
    
                                NxtDecimalNumberRange decimalnumberrange1 = new NxtDecimalNumberRange();
                                decimalnumberrange.IsMandatory = true;
                                decimalnumberrange.IsVisible = true;
                                decimalnumberrange.IsReadOnly = true;
                                script +=  decimalnumberrange1.ToScript(RenderMode.AddTo, containerPanel);
    Thanks
    Anulekha
    Last edited by Daniil; Feb 27, 2012 at 10:26 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Quote Originally Posted by AnulekhaK View Post
    1. I want to control the "allowblank" properties for the controls within the custom control by exposing a property (IsMandatory in below code). How to do this? The same behaviour is required for visible and readonly properties.
    Your implementation of the IsMandatory property appears to be correct. At least, it works in the example below.

    Could you provide more details what is going wrong on your side?

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        class MyFormPanel : FormPanel
        {
            TextField TextField1 = new TextField();
            
            public MyFormPanel()
            {
                this.Items.Add(this.TextField1);   
            }
    
            public bool IsMandatory
            {
                get 
                {
                    return !this.TextField1.AllowBlank;  
                }
                set
                {
                    this.TextField1.AllowBlank = !value;
                }
            }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            MyFormPanel mfp = new MyFormPanel();
            mfp.IsMandatory = true;
    
            this.Form.Controls.Add(mfp);
        }
    </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>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    Quote Originally Posted by AnulekhaK View Post
    2. When i add the same control twice, only one control is displayed. Please advise.
    Please keep one issue per one thread. So, please start a new froum thread.

Similar Threads

  1. Replies: 2
    Last Post: Jan 09, 2012, 7:18 AM
  2. Custom paging in grid has issues
    By getgopi1 in forum 1.x Help
    Replies: 8
    Last Post: Sep 22, 2010, 1:55 PM
  3. [CLOSED] Two issues with the gridpanel control.
    By seanwo in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2010, 7:19 PM
  4. Replies: 1
    Last Post: Sep 04, 2009, 9:14 AM
  5. [CLOSED] Issues in Tab Control
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 10, 2009, 4:38 AM

Posting Permissions