[CLOSED] Creating custom control on server side

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Creating custom control on server side

    HI,

    I need to create a timerange control on server side. how do i do this? Also i need to validate the values for "from" and "to" time.

    Please advise.

    Thanks
    Anulekha
    Last edited by Daniil; Feb 27, 2012 at 10:24 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I would inherit the control from, for example, Ext.Net.CompositeField or Ext.Net.Container, create two TimeFields controls within the control's constructor and place these TimeField's into the control's Items collection.

    How would you implement it in the markup?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I would inherit the control from, for example, Ext.Net.CompositeField or Ext.Net.Container, create two TimeFields controls within the control's constructor and place these TimeField's into the control's Items collection.

    How would you implement it in the markup?
    Hi Daniil.

    Inherting from customfield fixed my issue. Thank you. I am trying to validate the entries. My custom control is a number range control havng from and to text fields. I need to validate the upper and lower values. below is the code i am using now. This is function is executed any time.Please let me know if i am missing something.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Ext.Net;
    
    namespace NexiantSuite.NxtWebControls.Controls
    {
        public class CurrencyRange : CompositeField 
        {
            NxtNumberField FromCurrency = new NxtNumberField();
            NxtNumberField ToCurrency = new NxtNumberField();
    
            public CurrencyRange()
            {
                FromCurrency.ID = "FromCurrency";            
                FromCurrency.FieldLabel = "From";
                FromCurrency.Width = 100;
                FromCurrency.AllowBlank = false;
                FromCurrency.AllowDecimals = false;            
                FromCurrency.IndicatorIcon = Icon.BulletRed;
                FromCurrency.IsRemoteValidation = true;
                FromCurrency.RemoteValidation.Validation += new RemoteValidationDirectEvent.RemoteValidationEventHandler(FromCurrencyValidateEvent_Validation);
                
    
                ConfigItem FromCurrencyConfig = new ConfigItem();
                FromCurrencyConfig.Name = "ToCurrencyConfig";
                FromCurrencyConfig.Value = "#{ToCurrency}";
                FromCurrencyConfig.Mode = ParameterMode.Value;
                FromCurrency.CustomConfig.Add(FromCurrencyConfig);
                           
                ToCurrency.ID = "ToCurrency";           
                ToCurrency.FieldLabel = "To";
                ToCurrency.LabelAlign = Ext.Net.LabelAlign.Top;
                ToCurrency.Width = 100; 
                ToCurrency.AllowBlank = false;
                ToCurrency.AllowDecimals = false;            
                ToCurrency.IndicatorIcon = Icon.BulletRed;
                ToCurrency.IsRemoteValidation = true;            
                ToCurrency.RemoteValidation.Validation += new RemoteValidationDirectEvent.RemoteValidationEventHandler(ToCurrencyValidateEvent_Validation);
                
                ConfigItem ToCurrencyConfig = new ConfigItem();
                ToCurrencyConfig.Name = "FromCurrencyConfig";
                ToCurrencyConfig.Value = "#{FromCurrency}";
                ToCurrencyConfig.Mode = ParameterMode.Value;
                ToCurrency.CustomConfig.Add(ToCurrencyConfig);
    
                this.FieldLabel = "From";
                this.Items.Add(FromCurrency);            
                this.Items.Add(ToCurrency);            
            }
    
            void FromCurrencyValidateEvent_Validation(object sender, RemoteValidationEventArgs e)
            {            
                double FromCurrency = double.Parse(e.Value.ToString());
                if (!string.IsNullOrEmpty(ToCurrency.Value.ToString()))
                {
                    double toCurrency = double.Parse(ToCurrency.Value.ToString());
                    if (toCurrency > FromCurrency)
                    {
                        e.Success = true;
                    }
                    else
                    {
                        e.Success = false;
                        e.ErrorMessage = "";
                    }
                }
            }
    
            void ToCurrencyValidateEvent_Validation(object sender, RemoteValidationEventArgs e)
            {            
                double ToCurrency = double.Parse(e.Value.ToString());
                if (!string.IsNullOrEmpty(FromCurrency.Value.ToString()))
                {
                    double fromCurrency = double.Parse(FromCurrency.Value.ToString());
                    if (ToCurrency > fromCurrency)
                    {
                        e.Success = true;
                    }
                    else
                    {
                        e.Success = false;
                        e.ErrorMessage = "";
                    }
                }
            }
        }
    }
    Thanks
    Anulekha
  4. #4
    We can suggest the following solution.
    https://examples1.ext.net/#/Form/Val.../Custom_VType/
  5. #5
    Quote Originally Posted by Daniil View Post
    We can suggest the following solution.
    https://examples1.ext.net/#/Form/Val.../Custom_VType/
    Hi Daniil,


    I cannot do that. I am creating controls in server side and hence should do remote validation only.

    Thanks
    ANulekha
  6. #6
    Please clarify why can't you validate client side?
  7. #7
    Quote Originally Posted by Daniil View Post
    Please clarify why can't you validate client side?
    Hi Daniil,

    All the controls are created in a separte class library. This project doesnt not use js file and hence can not have any VType declared.

    Thanks
    Anulekha
  8. #8
    What about to register a required JavaScript as a part of the custom control.

    Then you will need to override the control Resources property.
    http://forums.ext.net/showthread.php...ll=1#post63023
  9. #9
    Quote Originally Posted by Daniil View Post
    What about to register a required JavaScript as a part of the custom control.

    Then you will need to override the control Resources property.
    http://forums.ext.net/showthread.php...ll=1#post63023
    HI Daniil,

    When i try to simulate the custom VTYpe example I am gettng error saying "EndDateField" is not defined for numberfield.

    Thanks
    Anulekha
  10. #10
    I'm not sure what you mean under "simulate".

    Well, you have a working example that I've referred. There is no "EndDateField".
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Server side custom GridPanel Column rendering
    By FAS in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 24, 2012, 2:45 PM
  2. Replies: 6
    Last Post: Aug 11, 2011, 7:30 PM
  3. [CLOSED] Creating custom control
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 29, 2010, 6:03 PM
  4. [CLOSED] [V1.0] TaskManager, Tasks (creating server side)
    By chafikb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 27, 2010, 3:45 AM
  5. Replies: 6
    Last Post: Sep 01, 2009, 1:06 PM

Posting Permissions