Ext.Net Plugin (JalaliDate for Persian Calendar)

  1. #1

    Ext.Net Plugin (JalaliDate for Persian Calendar)

    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Web.UI;
    
    namespace Ext.Net
    {
        [ToolboxItem(false)]
        [ToolboxBitmap(typeof(JalaliDate), "Build.ToolboxIcons.Plugin.bmp")]
        [ToolboxData("<{0}:JalaliDate runat=\"server\" />")]
        [Description("")]
        public partial class JalaliDate : Plugin
        {
            public JalaliDate()
            {
                
            }
    
            protected override List<ResourceItem> Resources
            {
                get
                {
                    List<ResourceItem> baseList = base.Resources;
                    baseList.Capacity += 4;
    
                    baseList.Add(new ClientScriptItem(typeof(JalaliDate), "Ext.Net.Build.Ext.Net.ux.plugins.JalaliDate.Jalali.js", "/ux/plugins/JalaliDate/Jalali.js"));
                    baseList.Add(new ClientScriptItem(typeof(JalaliDate), "Ext.Net.Build.Ext.Net.ux.plugins.JalaliDate.JalaliDate.js", "/ux/plugins/JalaliDate/JalaliDate.js"));
                    baseList.Add(new ClientScriptItem(typeof(JalaliDate), "Ext.Net.Build.Ext.Net.ux.plugins.JalaliDate.JalaliDatePlugin.js", "/ux/plugins/JalaliDate/JalaliDatePlugin.js"));
                    baseList.Add(new ClientScriptItem(typeof(JalaliDate), "Ext.Net.Build.Ext.Net.ux.plugins.JalaliDate.JalaliDatePlugin-fa_IR.js", "/ux/plugins/JalaliDate/JalaliDatePlugin-fa_IR.js"));
    
                    return baseList;
                }
            }
    
            [Category("0. About")]
            [Description("")]
            public override string InstanceOf
            {
                get
                {
                    return "Ext.ux.JalaliDatePlugin";
                }
            }
        }
    }
    using System.ComponentModel;
    using System.Xml.Serialization;
    using Newtonsoft.Json;
    
    namespace Ext.Net
    {
        public partial class JalaliDate
        {
            [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Always)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            [XmlIgnore]
            [JsonIgnore]
            public override ConfigOptionsCollection ConfigOptions
            {
                get
                {
                    ConfigOptionsCollection list = base.ConfigOptions;
    
                    return list;
                }
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Ext.Net
    {
        public partial class JalaliDate
        {
            public JalaliDate(Config config)
            {
                this.Apply(config);
            }
    
            public static implicit operator JalaliDate(JalaliDate.Config config)
            {
                return new JalaliDate(config);
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Ext.Net
    {
        public partial class JalaliDate
        {
            new public abstract partial class Builder<TJalaliDate, TBuilder> : Plugin.Builder<TJalaliDate, TBuilder>
                where TJalaliDate : JalaliDate
                where TBuilder : Builder<TJalaliDate, TBuilder>
            {
                public Builder(TJalaliDate component) : base(component) { }
    
            }
            public partial class Builder : JalaliDate.Builder<JalaliDate, JalaliDate.Builder>
            {
                public Builder() : base(new JalaliDate()) { }
    
                public Builder(JalaliDate component) : base(component) { }
    
                public Builder(JalaliDate.Config config) : base(new JalaliDate(config)) { }
    
                public static implicit operator Builder(JalaliDate component)
                {
                    return component.ToBuilder();
                }
            }
    
            public JalaliDate.Builder ToBuilder()
            {
                return Ext.Net.X.Builder.JalaliDate(this);
            }
    
            public override IControlBuilder ToNativeBuilder()
            {
                return (IControlBuilder)this.ToBuilder();
            }
        }
    
    
        public partial class BuilderFactory
        {
            public JalaliDate.Builder JalaliDate()
            {
                return this.JalaliDate(new JalaliDate { ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null });
            }
    
            public JalaliDate.Builder JalaliDate(JalaliDate component)
            {
                component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null;
                return new JalaliDate.Builder(component);
            }
    
            public JalaliDate.Builder JalaliDate(JalaliDate.Config config)
            {
                return new JalaliDate.Builder(new JalaliDate(config) { ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null });
            }
        }
    }
    This file contains needed js for this plugin
    http://www.4shared.com/rar/jnbohggrce/JalaliDate.html

    Now you can use date types as easy as this

    @Html.X().DateField().Plugins(Html.X().JalaliDate())
  2. #2
    Hello,

    Thanks for posting your sample.

    You and @hogaf appear to working on similar and/or complimentary functionality.

    http://hogaf.github.io/archive/2014/...t-2-5-3-pdate/

    http://forums.ext.net/showthread.php...ersian-date%29
    Geoffrey McGill
    Founder
  3. #3
    Hello Saman,

    Could you add a copy of the required files directly into a forum post? You can add between [CODE] tags.

    The link to the .rar download package may stop working at some point in the future, but adding inline within the forums should help preserve the code for future reference.

    As well, I wasn't actually able to download the .rar package from that third party site, so there's no way we can review and suggest improvements to your code.
    Geoffrey McGill
    Founder
  4. #4

    JalaliDate Files

    I upload all file in github

    https://github.com/saman-hosseini/Ext-Jalali
  5. #5

    Persian calendar problem.

    Hi there.
    Tanks about these useful controls but i have a problem. When i load these controls on a standalone window control everything works fine but when i load these controls on a page that must be loaded in desktop control i receive an error that tell me The resource can not be found. I find out that these controls can not find the embedded java scripts when they are used in a desktop control window. The problem is in this part of code:

    [Description("")]
    protected override List<ResourceItem> Resources
    {
    get
    {
    var baseList = base.Resources;
    baseList.Capacity += 3;

    baseList.Add(new ClientScriptItem(typeof(PDatePicker),
    "Diten.Web.UI.WebControls.PersianCalendar.Build.Ex t.Net.extjs.PDate.pdate.js", ""));
    baseList.Add(new ClientScriptItem(typeof(PDatePicker),
    "Diten.Web.UI.WebControls.PersianCalendar.Build.Ex t.Net.extjs.PDate.picker.PMonth.js", ""));
    baseList.Add(new ClientScriptItem(typeof(PDatePicker),
    "Diten.Web.UI.WebControls.PersianCalendar.Build.Ex t.Net.extjs.PDate.picker.PDate.js", ""));

    return baseList;
    }
    }

    Client Script Item can not find embedded java scripts when these controls are used as a content of a windows that is contained in desktop control. How could I solve this problem?

    Click image for larger version. 

Name:	Untitled1.jpg 
Views:	123 
Size:	103.7 KB 
ID:	24871

Similar Threads

  1. Calendar Panel Calendar Store
    By ozlem in forum 2.x Help
    Replies: 8
    Last Post: Apr 25, 2013, 8:02 AM
  2. Replies: 4
    Last Post: May 17, 2012, 12:36 PM
  3. Replies: 0
    Last Post: Jan 13, 2012, 2:33 PM
  4. Replies: 9
    Last Post: Apr 12, 2011, 3:13 PM

Tags for this Thread

Posting Permissions