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

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.
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?
Plamen
the Telerik team

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?
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?
Plamen
the Telerik team

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.
Plamen
the Telerik team

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
>
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
>
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

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">
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.
Plamen
the Telerik team
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.
Plamen
the Telerik team

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.
Plamen
the Telerik team

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?
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.
Plamen
the Telerik team
Yes indeed unfortunately this is a limitation of RadCalendar control in such scenario.
Plamen
the Telerik team

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.
