[CLOSED] Subclassed/extended DateField

  1. #1

    [CLOSED] Subclassed/extended DateField

    I need to extend the DateField form control to override the client-side getValue method, but I'm getting a bit stuck on the C# control code and the Javascript code. There seems to be a number of ways of extending ExtJS components and I'm not sure which one to use.

    Can someone post some boilerplate code or point me to a good example of Ext.NET webcontrol code that subclasses an existing Ex.NET / ExtJS component?

    Thanks in advance
    Last edited by Daniil; Mar 28, 2011 at 1:25 PM. Reason: [CLOSED]
  2. #2
  3. #3
    Thanks for those links. I've also looked at the UX components in the Ext.Net source. I'm still encountering problems however...

    I've created my control but when I try to include it in a FormLayout (within an anchor tag), I get the warning:
    Generation of designer file failed: Ext.Net.ItemsCollection`1[[Ext.Net.Component, Ext.Net, Version=1.0.3960.36328, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87]] must have items of type 'Ext.Net.Component'. 'cc1:DateOnlyField' is of type XXX.Foundation.WebUI.Controls.ExtJs.DateOnlyField'.
    The C# control/component class
    namespace XXX.Foundation.WebUI.Controls.ExtJs
    {
        [Meta]
        [ToolboxData("<{0}:DateOnlyField runat=\"server\" />")]
        [Description("Provides a date-only input field with a DatePicker dropdown and automatic date validation.")]
        public class DateOnlyField : Ext.Net.DateField
        {
            public override string InstanceOf
            {
                get
                {
                    return "Ext.ux.DateOnlyField";
                }
            }
    
            public override string XType
            {
                get
                {
                    return "dateonlyfield";
                }
            }
    
            protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
                    baseList.Capacity++;
    
                    baseList.Add(new ClientScriptItem(typeof(DateOnlyField), "XXX.Foundation.WebUI.Controls.ExtJs.DateOnlyField.js", "/Controls/ExtJs/DateOnlyField.js"));
    
                    return baseList;
    
                }
            }
        }
    Client-side javascript
    Ext.ns("Ext.ux.form");
    
    Ext.ux.form.DateOnlyField = Ext.extend(Ext.form.DateField, {
    
        constructor: function(config) {
            config = config || {};
            Ext.ux.form.DateOnlyField.superclass.constructor.apply(this, arguments);
        },
    
        getValue: function() {
            debugger;
            var v = Ext.ux.form.DateOnlyField.superclass.getValue.apply(this, arguments);
            if (!!v) return v.add(Date.MINUTE, -1 * v.getTimezoneOffset()); //get back to "correct" date
            else return null;
        }
    
    });
    
    Ext.reg('dateonlyfield', Ext.ux.form.DateOnlyField);
    
    Ext.ux.DateOnlyField = Ext.ux.form.DateOnlyField;
    What am I missing or doing wrong?
  4. #4
    Hi,

    I guess it is VS designer bug. Just try to run your sample, it should run ok
  5. #5
    Quote Originally Posted by Vladimir View Post
    Hi,

    I guess it is VS designer bug. Just try to run your sample, it should run ok
    It does run okay

    Thanks, you can maked this one as CLOSED

Similar Threads

  1. Replies: 12
    Last Post: Jul 02, 2013, 4:44 AM
  2. Replies: 1
    Last Post: Aug 05, 2011, 11:15 AM
  3. [CLOSED] Need help for FileUpload from subclassed window
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Jul 12, 2011, 12:21 PM
  4. [CLOSED] Call DirectMethod from subclassed control
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 08, 2011, 10:05 AM
  5. Replies: 2
    Last Post: Dec 17, 2009, 2:32 PM

Posting Permissions