This is a migrated thread and some comments may be shown as answers.

RadScheduler problem with Persian Calendar

20 Answers 300 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
shahab
Top achievements
Rank 1
shahab asked on 13 Mar 2013, 08:49 PM
Dear Support Team
I have a problem in localization RadScheduler. I used InsertAdvancedForm with userControl as mentioned in demo. Everything about Persian Calendar is Ok Just in AdvancedForm. When I want to select Date Persian Calendar is opened but in RadDatePicker date is in Georgian Format:

20 Answers, 1 is accepted

Sort by
0
shahab
Top achievements
Rank 1
answered on 13 Mar 2013, 08:51 PM
I Used this Class to Localize RadScheduler to Persian Calendar:
using System.Globalization;
using System.Collections.Generic;
using System;
using System.Reflection;
public class PersianCulture : CultureInfo
{
    private readonly Calendar cal;
    private readonly Calendar[] optionals;


    public PersianCulture()
        : this("fa-IR", true)
    {
    }

    public PersianCulture(string cultureName, bool useUserOverride)
        : base(cultureName, useUserOverride)
    {
        //Temporary Value for cal.
        cal = base.OptionalCalendars[0];

        //populating new list of optional calendars.
        var optionalCalendars = new List<Calendar>();
        optionalCalendars.AddRange(base.OptionalCalendars);
        optionalCalendars.Insert(0, new PersianCalendar());


        Type formatType = typeof(DateTimeFormatInfo);
        Type calendarType = typeof(Calendar);


        PropertyInfo idProperty = calendarType.GetProperty("ID", BindingFlags.Instance | BindingFlags.NonPublic);
        FieldInfo optionalCalendarfield = formatType.GetField("optionalCalendars",
                                                              BindingFlags.Instance | BindingFlags.NonPublic);

        //populating new list of optional calendar ids
        var newOptionalCalendarIDs = new Int32[optionalCalendars.Count];
        for (int i = 0; i < newOptionalCalendarIDs.Length; i++)
            newOptionalCalendarIDs[i] = (Int32)idProperty.GetValue(optionalCalendars[i], null);

        optionalCalendarfield.SetValue(DateTimeFormat, newOptionalCalendarIDs);

        optionals = optionalCalendars.ToArray();
        cal = optionals[0];
        DateTimeFormat.Calendar = optionals[0];

        DateTimeFormat.MonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
        DateTimeFormat.MonthGenitiveNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
        DateTimeFormat.AbbreviatedMonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
        DateTimeFormat.AbbreviatedMonthGenitiveNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };


        DateTimeFormat.AbbreviatedDayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };//{ "ی", "د", "س", "چ", "پ", "ج", "ش" };
        DateTimeFormat.ShortestDayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };//{ "ی", "د", "س", "چ", "پ", "ج", "ش" };
        DateTimeFormat.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };

        DateTimeFormat.AMDesignator = "ق.ظ";
        DateTimeFormat.PMDesignator = "ب.ظ";

        /*
        DateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
        DateTimeFormat.LongDatePattern = "yyyy/MM/dd";
             
        DateTimeFormat.SetAllDateTimePatterns(new[] {"yyyy/MM/dd"}, 'd');
        DateTimeFormat.SetAllDateTimePatterns(new[] {"dddd, dd MMMM yyyy"}, 'D');
        DateTimeFormat.SetAllDateTimePatterns(new[] {"yyyy MMMM"}, 'y');
        DateTimeFormat.SetAllDateTimePatterns(new[] {"yyyy MMMM"}, 'Y');
         */

    }

    public override Calendar Calendar
    {
        get { return cal; }
    }

    public override Calendar[] OptionalCalendars
    {
        get { return optionals; }
    }
}

And in Global.asax:
 protected void Application_BeginRequest(object sender, EventArgs e)
    {
        var persianCulture = new PersianCulture();
        System.Threading.Thread.CurrentThread.CurrentCulture = persianCulture;
        System.Threading.Thread.CurrentThread.CurrentUICulture = persianCulture;
    }
everything is ok just in select start and end date.
0
Plamen
Telerik team
answered on 18 Mar 2013, 12:29 PM
Hello shahab,

 
Would you please share what is the expected way the calendar should be looking and if it is looking properly when RadDatePicker is outside RadScheduler as a separate control?

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 18 Mar 2013, 12:45 PM
1.Picture sd.png:
I found mentioned class to conver georgian Calendar to Persian Calendar. Everything in ok but when user change time in RadDatePicker popup Caledar (1391/12/08) is in persian but in DateInput is in georgian format(2013/03/05). I mean DateInput should be 1391/12/08 when I select year 1391, day 08 and month 12 in calendar.

2.Picture moffiederror.png:
I have this problem in updating appointment with mouse click in main page. when I press mouse down and change start time of appointment I got an error because start Time is changed therefore is in georgian format but endtime is not changed therefore is in Persian Format. Persian year is less than georgian. I've got error: StartTIme should be less than endTime.
I solved problem in this type. I changed Starttime to Georgian in PatientScheduler_AppointmentUpdate with a trick(endtime and startTime variables are used to store modified time of Day):
  protected void PatientScheduler_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
    {
        TimeSpan endTime = e.ModifiedAppointment.End.TimeOfDay;
        e.ModifiedAppointment.End = e.Appointment.End;
        e.ModifiedAppointment.End = e.ModifiedAppointment.End.Add(endTime - e.ModifiedAppointment.End.TimeOfDay);

        TimeSpan startTime = e.ModifiedAppointment.Start.TimeOfDay;
        e.ModifiedAppointment.Start = e.Appointment.Start;        
        e.ModifiedAppointment.Start = e.ModifiedAppointment.Start.Add(startTime - e.ModifiedAppointment.Start.TimeOfDay);

        if (e.ModifiedAppointment.Start > e.ModifiedAppointment.End)
        {
            e.Cancel = true;
            //TODO: Exceptio Handeling
            throw new Exception("start time must be before end time");
        }
}

The main problem is why date-time change to Georgian format with this class? Is there any solution to convert it to Persian Format in clientside?
0
Plamen
Telerik team
answered on 04 Apr 2013, 08:04 AM
Hello shahab,

 
I have been inspecting the scenario you are trying to implement but could not make the RadScheduler insert and update appointments correctly even after using the code that you shared so far. Would you please elaborate if any other code should be added as well in order do this?

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 04 Apr 2013, 08:24 AM
Would you make user on Tfs.VisualStudio.com? I want to add your user to project to check it. I used own solution but it is not good solution. I have many problem with RadScheduler in Persian Format. I solved most of them but I regret to use it. I can not forget Telerik because I do more than 60% of Project.
0
Plamen
Telerik team
answered on 04 Apr 2013, 08:54 AM
Hi shahab,

 
Unfortunately RadScheduler does not support PersianCalendar so far and that is why it is expected that there are some errors in its functionality when trying to add it. I have isolated the scenario in a sample web page would you please review it and let me know what else should be added so it works the same way as at your side.

This way we will be able to inspect the issues faced and be more helpful.

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 04 Apr 2013, 09:58 AM
Dear Plamen,
I don't what's happen when start in advancedForm but it work with this solution:
<telerik:RadScheduler runat="server" ID="RadScheduler1"
     EditFormDateFormat="yyyy/MM/dd" 
     OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentInsert="RadScheduler1_AppointmentInsert"  SelectedView="MonthView"  
    HoursPanelTimeFormat="HH:mm"
              StartInsertingInAdvancedForm="True"
            StartEditingInAdvancedForm="True">         
   <MonthView HeaderDateFormat="MMM dd"  DayHeaderDateFormat="MMM dd"/>
         </telerik:RadScheduler>
As highlighted in picture I Select start time in Insert mode therefore DateInput change to Georgian but  I do not change endtime therefore it is in Persian. I can not attach project. I just Change .aspx form.
I can Add this to .xml:
<Appointment>
   <ID>56</ID>
   <Subject>ghhgjghj</Subject>
   <Start>2013-04-04T15:00Z</Start>
   <End>2013-04-09T16:00Z</End>
   <Resources>
     <Room Key="1" />
     <User Key="1" />
   </Resources>
 </Appointment>
0
Plamen
Telerik team
answered on 04 Apr 2013, 10:31 AM
Hello shahab,

 
Thank you for providing more information about the issue. You will have to change the dates in the date pickers from the server. Here is the code that will let you achieve it:

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
  {
      RadDatePicker startDate = e.Container.FindControl("StartDate") as RadDatePicker;
      startDate.AutoPostBack = true;
      RadDatePicker endDate = e.Container.FindControl("EndDate") as RadDatePicker;
      endDate.AutoPostBack = true;
  }

Hope this will be helpful.

Kind regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 04 Apr 2013, 10:51 AM
It is not ok yet!
e.ModifiedAppointment.Start is in GeorgianFormat and  e.ModifiedAppointment.End is In Persian Format. Because I Change EndTime.

WHen I Set
<telerik:RadDatePicker runat="server" ID="StartDate" CssClass="rsAdvDatePicker"   Width="150px" SharedCalendarID="SharedCalendar" Skin='<%# Owner.Skin %>' Culture='<%# Owner.Culture %>'     MinDate="1900-01-01" AutoPostBack="True">
It id ok just first time. After change selection Persian Calendar  change to Georgian
0
Plamen
Telerik team
answered on 04 Apr 2013, 12:20 PM
Hi shahab,

 
After making both DatePickers AutoPostBack true they updated their time to Persian time accordingly without any code in the AppointmentUpdateEvent. I am attaching an updated sample web page again. Here is a video of my test. Please review it and let us know if you have further questions.

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 04 Apr 2013, 07:27 PM
Dear Plamen
Change starttime/endtime more than once. At first every thing is ok (2.png). DateInput and PopupCalendar are in Persian Format but after two or more times it is in Georgian format(1.png)
0
Plamen
Telerik team
answered on 05 Apr 2013, 12:14 PM
Hi shahab,

 
Here is a video of my test. Please review it and let me know if I am not testing properly or I have to do something else.

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 05 Apr 2013, 02:50 PM
Please notice in the movie when you want to select time from pop calendar it is in georgian Format "آفریل 2013" is Arabic format of "April 2013". I highlighted correct popup calendar in previous images. Please notice my goal is popup calendar(you check datainput)
0
Plamen
Telerik team
answered on 08 Apr 2013, 09:54 AM
Hello shahab,

 
This behavior looks like a limitation of the current behavior that can not be workarounded because the  input is populated on the client. Yet after a date is selected the information is updated from the server and the appointment is generated properly.

Hope this will explain the issue. If you have further questions please feel free to contact us again. 

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
shahab
Top achievements
Rank 1
answered on 08 Apr 2013, 05:24 PM
Dear Plamen
I do not understand what do you mean. Why in the first time popup calendar is in Persian date format but when select multi-times it changes to date Georgian format?
0
Plamen
Telerik team
answered on 12 Apr 2013, 07:12 AM
Hi shahab,

 
This issue looks like a limitation of this scenario but I will research it deeper and will let you know if I could find a workaround for it.

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Plamen
Telerik team
answered on 10 May 2013, 06:13 AM
Hello,

 
Yes indeed unfortunately this is a limitation of RadCalendar control in such scenario.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Vahid
Top achievements
Rank 1
answered on 04 Jan 2015, 12:07 PM
Is there any improvement in this context?
0
Plamen
Telerik team
answered on 05 Jan 2015, 06:53 AM
Hello Vahid,

Unfortunately this is a limitation oi the control and there is no workaround for it. 

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mohamad Javad
Top achievements
Rank 1
Iron
answered on 18 Apr 2015, 03:44 AM
http://www.telerik.com/forums/problem-changing-the-calender-to-persian
Tags
Scheduler
Asked by
shahab
Top achievements
Rank 1
Answers by
shahab
Top achievements
Rank 1
Plamen
Telerik team
Vahid
Top achievements
Rank 1
Mohamad Javad
Top achievements
Rank 1
Iron
Share this question
or