Why Calendar cannot render with EventStore?

  1. #1

    Why Calendar cannot render with EventStore?

    Hi all! Sorry, my english is too bad :)
    Today, I use CalendarPanel in first time, and i wonder why my CalendarPanel can't render full if i put any events to it. It only display at Month view, but Week view and Day view are blank. I can't do anything if event in CalendarPanel.


    <!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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
     
        <script type="text/javascript">
            var CompanyX = {
                getWindow: function () {
                    return CompanyX.EventEditWindow1;
                },
    
                dayClick: function (cal, dt, allDay, el) {
                    this.record.show.call(this, cal, {
                        StartDate: dt,
                        IsAllDay: allDay
                    }, el);
                },
    
                record: {
                    show: function (cal, rec, el) {
                        CompanyX.getWindow().show(rec, el);
                    }
                }
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="CompanyX" />
        <ext:Viewport ID="Viewport1" runat="server">
            <Items>
                <ext:CalendarPanel ID="CalendarPanel1" runat="server" Height="500">
                    <EventStore ID="EventStore1" runat="server" >
                        <Events>
                                <ext:Event
                                EventId="0"
                                Title="My event 1"
                                StartDate="2012/3/15"
                                EndDate="2012/3/18"
                                CalendarId="1" />
                        </Events>
                    </EventStore>
                    <GroupStore ID="GroupStore1" runat="server">
                        <Groups>
                            <ext:Group CalendarId="1" Title="Work" />
                        </Groups>
                    </GroupStore>
                    <Listeners>
                        <DayClick Fn="CompanyX.dayClick" Scope="CompanyX" />
                    </Listeners>
                </ext:CalendarPanel>
            </Items>
        </ext:Viewport>
        <ext:EventEditWindow
            ID="EventEditWindow1"
            runat="server"
            Hidden="true"
            GroupStoreID="GroupStore1">
            <Listeners>
                <Render Handler="var titleItem = this.formPanel.get('title'),
                    dateRangeItem = this.formPanel.get('date-range'),
                    calendarItem = this.formPanel.get('calendar');
                    titleItem.id = 'titleId'; 
                    titleItem.fieldLabel = 'My Title';
                    titleItem.dataIndex = 'Title'" />
            </Listeners>
        </ext:EventEditWindow>
        </form>
    </body>
    </html>
    And result is :
    Click image for larger version. 

Name:	monthview.png 
Views:	152 
Size:	26.5 KB 
ID:	3955Click image for larger version. 

Name:	weekview.png 
Views:	134 
Size:	10.9 KB 
ID:	3956

    And it works fine when i remove

    <Events>
           <ext:Event
           EventId="0"
           Title="My event 1"
           StartDate="2012/3/15"
           EndDate="2012/3/18"
           CalendarId="1" />
    </Events>

    Click image for larger version. 

Name:	bt.png 
Views:	186 
Size:	27.0 KB 
ID:	3957Click image for larger version. 

Name:	bt2.png 
Views:	167 
Size:	19.8 KB 
ID:	3958
  2. #2
    Hi,

    I was unable to reproduce the problem.

    Please clarify: what browser and Ext.NET version are you testing with?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I was unable to reproduce the problem.

    Please clarify: what browser and Ext.NET version are you testing with?
    Hi, I testing with Ext.NET Community v.1.3.0 and Chrome v.17.0 + IE v.8.0.

    When I try to use a class that inherits from class Ext.net.Event then it works fine.

    class MyEvent : Event {}
    
    protected void Page_Load(object sender, EventArgs e)
    {
                if (!X.IsAjaxRequest)
                {
                    var store = this.CalendarPanel1.EventStore;
                    
                    this.CalendarPanel1.EventStore.AddStandardFields();
                    RecordField rf = this.CalendarPanel1.EventStore.Reader[0].Fields.Get("StartDate");
                    rf.Mapping = "StartDate";
                    rf = this.CalendarPanel1.EventStore.Reader[0].Fields.Get("EndDate");
                    rf.Mapping = "EndDate";
    
                    List<MyEvent> lstEvent = new List<MyEvent>();
                    MyEvent newEvent = new MyEvent();
                    newEvent .CalendarId = 1;
                    newEvent .EventId = 1;
                    newEvent .Title = "Test";
                    newEvent .StartDate = DateTime.Now;
                    newEvent .EndDate = DateTime.Now.AddDays(3);
                    newEvent .Notes = "Test OK";
    
                    lstEvent.Add(newEvent);
                    store.DataSource = lstEvent;
                    store.DataBind();
            }
    }
    But if i use Ext.net.Event class to show my event, then Calendar isn't work. It's like crash, week view and day view are blank, i can't click on calendar. The only thing it shows is the current month and not have any events yet. You can see 2 pictures below
    Click image for larger version. 

Name:	monthview.png 
Views:	151 
Size:	26.5 KB 
ID:	3960Click image for larger version. 

Name:	weekview.png 
Views:	127 
Size:	10.9 KB 
ID:	3961
  4. #4
    Reproduced with v1.3. There is a bug.

    We hope to release v1.3.1 soon.

    To fix it right now you will need to:

    1. Download the full v1.3 sources:
    http://www.ext.net/archives/1-3-0/ex...ull.source.zip

    2. Replace the following files from the Ext.Net\Utility\JsonConverters\ folder:

    CtorDateTimeJsonConverter.cs
    ISODateTimeJsonConverter.cs
    JSONDateTimeJsonConverter.cs

    with the ones below.

    3. Build the solution and use the new dlls.

    CtorDateTimeJsonConverter.cs
    /********
     * @version   : 1.3.0 - Ext.NET Pro License
     * @author    : Ext.NET, Inc. http://www.ext.net/
     * @date      : 2012-02-21
     * @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
     * @license   : See license.txt and http://www.ext.net/license/. 
     ********/
    
    using System;
    using System.ComponentModel;
    
    using Newtonsoft.Json;
    
    namespace Ext.Net
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("")]
        public partial class CtorDateTimeJsonConverter : ExtJsonConverter
        {
            /// <summary>
            /// 
            /// </summary>
            [Description("")]
            public override bool CanConvert(Type valueType)
            {
                return (typeof(DateTime).IsAssignableFrom(valueType)
                  || typeof(DateTime?).IsAssignableFrom(valueType));
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Description("")]
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                if (value is DateTime || value is DateTime?)
                {
                    DateTime date = value is DateTime ? (DateTime)value : (value as DateTime?).Value;
    
                    if (date.Equals(DateTime.MinValue))
                    {
                        writer.WriteRawValue("null");
                    }
                    else
                    {
                        string template = (date.TimeOfDay == new TimeSpan(0, 0, 0)) ? "{0},{1},{2}" : "{0},{1},{2},{3},{4},{5}";
    
                        writer.WriteStartConstructor("Date");
                        writer.WriteRawValue(
                            string.Format(template, date.Year, date.Month - 1, date.Day,
                                          date.Hour, date.Minute, date.Second));
                        writer.WriteEndConstructor();
                    }
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Description("")]
            public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                throw new NotImplementedException();
            }
        }
    }
    ISODateTimeJsonConverter.cs
    /********
     * @version   : 1.3.0 - Ext.NET Pro License
     * @author    : Ext.NET, Inc. http://www.ext.net/
     * @date      : 2012-02-21
     * @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
     * @license   : See license.txt and http://www.ext.net/license/. 
     ********/
    
    using System;
    using System.Globalization;
    using Newtonsoft.Json;
    using Ext.Net.Utilities;
    
    namespace Ext.Net
    {
        // ISODateTimeJsonConverter based on Newtonsoft.Json.Converters.IsoDateTimeConverter
        // The DateTimeFormat const was changed to remove the millisecond format specifier. 
        // Copyright (c) 2007 James Newton-King
    
        /// <summary>
        /// Converts a <see cref="DateTime"/> to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).
        /// </summary>
        public partial class ISODateTimeJsonConverter : ExtJsonConverter
        {
            private const string DateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss";
    
            private DateTimeStyles dateTimeStyles = DateTimeStyles.RoundtripKind;
    
            /// <summary>
            /// Gets or sets the date time styles used when converting a date to and from JSON.
            /// </summary>
            /// <value>The date time styles used when converting a date to and from JSON.</value>
            public DateTimeStyles DateTimeStyles
            {
                get { return dateTimeStyles; }
                set { dateTimeStyles = value; }
            }
    
            /// <summary>
            /// Writes the JSON representation of the object.
            /// </summary>
            /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
            /// <param name="value">The value.</param>
            /// <param name="serializer">Serializer</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                string text;
    
                if (value is DateTime || value is DateTime?)
                {
                    DateTime dateTime = value is DateTime ? (DateTime)value : (value as DateTime?).Value;
                    if ((dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
                      || (dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
                    {
                        dateTime = dateTime.ToUniversalTime();
                    }
    
                    text = dateTime.ToString(ISODateTimeJsonConverter.DateTimeFormat, CultureInfo.InvariantCulture);
                }
                else
                {
                    DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
    
                    if ((dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
                      || (dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
                        dateTimeOffset = dateTimeOffset.ToUniversalTime();
    
                    text = dateTimeOffset.ToString(DateTimeFormat, CultureInfo.InvariantCulture);
                }
    
                writer.WriteValue(text);
            }
    
            /// <summary>
            /// Reads the JSON representation of the object.
            /// </summary>
            /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
            /// <param name="objectType">Type of the object.</param>
            /// <param name="existingValue">Existing Value</param>
            /// <param name="serializer">Serializer</param>
            /// <returns>The object value.</returns>
            public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.Null && objectType.IsAssignableFrom(typeof(DateTime?)))
                {
                    return null;
                }
    
                if (reader.TokenType != JsonToken.String)
                {
                    throw new Exception("Unexpected token parsing date. Expected String, got {0}.".FormatWith(reader.TokenType));
                }
    
                string dateText = reader.Value.ToString();
    
                if (objectType == typeof(DateTimeOffset))
                {
                    return DateTimeOffset.Parse(dateText, CultureInfo.InvariantCulture, dateTimeStyles);
                }
    
                return DateTime.Parse(dateText, CultureInfo.InvariantCulture, dateTimeStyles);
            }
    
            /// <summary>
            /// Determines whether this instance can convert the specified object type.
            /// </summary>
            /// <param name="objectType">Type of the object.</param>
            /// <returns>
            ///     <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
            /// </returns>
            public override bool CanConvert(Type objectType)
            {
                return (typeof(DateTime).IsAssignableFrom(objectType)
                  || typeof(DateTime?).IsAssignableFrom(objectType)
                  || typeof(DateTimeOffset).IsAssignableFrom(objectType));
            }
        }
    }
    JSONDateTimeJsonConverter.cs
    /********
     * @version   : 1.3.0 - Ext.NET Pro License
     * @author    : Ext.NET, Inc. http://www.ext.net/
     * @date      : 2012-02-21
     * @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
     * @license   : See license.txt and http://www.ext.net/license/. 
     ********/
    
    using System;
    using System.Globalization;
    using Newtonsoft.Json;
    using Ext.Net.Utilities;
    
    namespace Ext.Net
    {
        // JSONDateTimeJsonConverter based on Newtonsoft.Json.Converters.IsoDateTimeConverter
        // The JSONDateTimeJsonConverter returns the server's local time.
        // Copyright (c) 2007 James Newton-King
    
        /// <summary>
        /// Converts a <see cref="DateTime" /> to and from the ISO 8601 date format (e.g. 2008-04-12T12:53) using the server
        /// time. Does not adjust for timezone.
        /// </summary>
        public partial class JSONDateTimeJsonConverter : ExtJsonConverter
        {
            private const string DateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss.fff";
    
            /// <summary>
            /// Writes the JSON representation of the object.
            /// </summary>
            /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
            /// <param name="value">The value.</param>
            /// <param name="serializer">Serializer</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                if (value is DateTime || value is DateTime?)
                {
                    DateTime date = value is DateTime ? (DateTime)value : (value as DateTime?).Value;
    
                    if (date != DateTime.MinValue)
                    {
                        writer.WriteValue(date.ToString(DateTimeFormat, CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        writer.WriteRawValue("null");
                    }
    
                    return;
                }
                else
                {
                    DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
    
                    if (dateTimeOffset != DateTimeOffset.MinValue)
                    {
                        writer.WriteValue(dateTimeOffset.ToString(DateTimeFormat, CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        writer.WriteRawValue("null");
                    }
                }
    
                writer.WriteRawValue("null");
            }
    
            /// <summary>
            /// Reads the JSON representation of the object.
            /// </summary>
            /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
            /// <param name="objectType">Type of the object.</param>
            /// <param name="existingValue">Existing Value</param>
            /// <param name="serializer">Serializer</param>
            /// <returns>The object value.</returns>
            public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.Null && objectType.IsAssignableFrom(typeof(DateTime?)))
                {
                    return null;
                }
    
                if (reader.TokenType != JsonToken.String)
                {
                    throw new Exception("Unexpected token parsing date. Expected String, got {0}.".FormatWith(reader.TokenType));
                }
    
                if (reader.Value.ToString().IsEmpty())
                {
                    return null;
                }
    
                return DateTime.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
            }
    
            /// <summary>
            /// Determines whether this instance can convert the specified object type.
            /// </summary>
            /// <param name="objectType">Type of the object.</param>
            /// <returns>
            ///     <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
            /// </returns>
            public override bool CanConvert(Type objectType)
            {
                return (typeof(DateTime).IsAssignableFrom(objectType)
                  || typeof(DateTime?).IsAssignableFrom(objectType)
                  || typeof(DateTimeOffset).IsAssignableFrom(objectType));
            }
        }
    }
  5. #5
    Hi Daniil, thank so much your support :)

    I think my problem is solved, it work fine.
    I have read many topics discussed how to custom EventEditWindow in forum. But i want to use my FormPanel what to get, add, update, delete events.
    I don't know how to get event into my own FormPanel. And a small question, how to hide some elements example : Location, Remind, Web link.

    Hope your help :D
  6. #6
    Please keep one issue per one thread.

Similar Threads

  1. [CLOSED] SchedulerGrid EventStore
    By Adrian in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 17, 2012, 3:53 AM
  2. Replies: 7
    Last Post: May 15, 2012, 11:27 AM
  3. Replies: 1
    Last Post: Jul 07, 2011, 4:07 PM
  4. [CLOSED] Calendar - EventStore.SubmitData
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 17, 2011, 11:46 PM
  5. [CLOSED] EventStore and REST API
    By craig2005 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 04, 2011, 3:19 PM

Posting Permissions