Hi,
I have an issue refreshing a radscheduler using Telerik ajax
My page contains a RadTabStrip, one of which is containing a RadScheduler.
When I update one of my page element using Telerik ajax, I would like my scheduler to be regreshed but despite my Appointments list is being refreshed server side, the scheduler is not refreshed clietn side whereas another ajaxified field is.
I have readed many threads on the forum but i still did not find a solution
Below are some extract of the code:
.aspx
.aspx.cs
When debugging step by step, I update appointments list but it never appears correctly on client side
Moreover, if my appointment list is empty at first load, depending on my browser, the radscheduler is sometimes shrinked with a javascript error in the axd file..
If any one has a good idea....it would be greatly appreciated
Regards.
I have an issue refreshing a radscheduler using Telerik ajax
My page contains a RadTabStrip, one of which is containing a RadScheduler.
When I update one of my page element using Telerik ajax, I would like my scheduler to be regreshed but despite my Appointments list is being refreshed server side, the scheduler is not refreshed clietn side whereas another ajaxified field is.
I have readed many threads on the forum but i still did not find a solution
Below are some extract of the code:
.aspx
<
telerik:RadAjaxManager
ID
=
"PageRadAjaxManager"
runat
=
"server"
OnAjaxRequest
=
"PageRadAjaxManager_AjaxRequest"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"PageRadAjaxManager"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"TxtIltExtid"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"InstructorId"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"LblInstructorName"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"IltRoomId"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"LblIltRoomName"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"InstructorRadGrid"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"DiaryRadScheduler"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"InstructorRadGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"InstructorRadGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"DiaryRadScheduler"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"DiaryRadScheduler"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadPageView
runat
=
"server"
ID
=
"lsched_diary_pv"
TabIndex
=
"2"
>
<
div
class
=
"LschedAdminContent"
>
<
br
/>
<
telerik:radscheduler
runat
=
"server"
id
=
"DiaryRadScheduler"
DataKeyField
=
"ID"
DataSubjectField
=
"Subject"
DataStartField
=
"Start"
DataEndField
=
"End"
DataDescriptionField
=
"Description"
DataRecurrenceField
=
"RecurrenceRule"
DataRecurrenceParentKeyField
=
"RecurrenceParentId"
DataReminderField
=
"Reminder"
OnAppointmentDataBound
=
"DiaryRadScheduler_AppointmentDataBound"
AllowDelete
=
"false"
AllowEdit
=
"false"
AllowInsert
=
"false"
EnableDescriptionField
=
"true"
EnableRecurrenceSupport
=
"false"
EnableResourceEditing
=
"false"
EnableExactTimeRendering
=
"false"
DayStartTime
=
"08:00:00"
DayEndTime
=
"20:00:00"
WorkDayStartTime
=
"08:00:00"
WorkDayEndTime
=
"20:00:00"
WeekView-DayStartTime
=
"08:00:00"
WeekView-DayEndTime
=
"20:00:00"
WeekView-WorkDayStartTime
=
"08:00:00"
WeekView-WorkDayEndTime
=
"20:00:00"
WeekView-EnableExactTimeRendering
=
"true"
MultiDayView-DayStartTime
=
"08:00:00"
MultiDayView-DayEndTime
=
"20:00:00"
MultiDayView-WorkDayStartTime
=
"08:00:00"
MultiDayView-WorkDayEndTime
=
"20:00:00"
MultiDayView-NumberOfDays
=
"5"
MultiDayView-EnableExactTimeRendering
=
"true"
AppointmentStyleMode
=
"Auto"
SelectedView
=
"WeekView"
StartEditingInAdvancedForm
=
"true"
StartInsertingInAdvancedForm
=
"true"
ShowHeader
=
"true"
ShowFooter
=
"true"
ShowAllDayRow
=
"false"
ShowDateHeaders
=
"true"
ShowFullTime
=
"false"
OverflowBehavior
=
"Expand"
RowHeight
=
"25px"
RowHeaderWidth
=
"50px"
MinutesPerRow
=
"60"
TimeLabelRowSpan
=
"2"
FirstDayOfWeek
=
"Monday"
LastDayOfWeek
=
"Sunday"
HoursPanelTimeFormat
=
"HH:mm tt"
OnResourceHeaderCreated
=
"DiaryRadScheduler_ResourceHeaderCreated"
GroupBy
=
"Type"
>
<
DayView
HeaderDateFormat
=
"d"
UserSelectable
=
"true"
/>
<
WeekView
HeaderDateFormat
=
"d"
UserSelectable
=
"true"
/>
<
MonthView
HeaderDateFormat
=
"d"
UserSelectable
=
"true"
/>
<
AgendaView
HeaderDateFormat
=
"d"
UserSelectable
=
"false"
/>
<
TimelineView
UserSelectable
=
"false"
/>
<
MultiDayView
UserSelectable
=
"false"
/>
<
AdvancedForm
Modal
=
"true"
/>
<
ResourceHeaderTemplate
>
<
asp:Panel
ID
=
"HeaderLabelWrapper"
runat
=
"server"
>
<%# Eval("Text") %>
</
asp:Panel
>
</
ResourceHeaderTemplate
>
<
AppointmentTemplate
>
<%# Eval("Subject") %><
br
/><%# Eval("Description") %>
</
AppointmentTemplate
>
</
telerik:radscheduler
>
</
div
>
</
telerik:RadPageView
>
.aspx.cs
...
using
Telerik.Web.UI;
...
namespace
WBTManager.manageILT
{
public
partial
class
lsched : System.Web.UI.Page
{
#region Variables
...
List<AppointmentInfo> Appointments =
new
List<AppointmentInfo>();
#endregion Variables
protected
void
Page_Init(
object
sender, EventArgs e)
{
...
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
#region Session or ViewState
...
if
(ViewState[
"Appointments"
] !=
null
)
Appointments = (List<AppointmentInfo>)ViewState[
"Appointments"
];
#endregion Session or ViewState
if
(!IsPostBack)
{
...
#region Fill values
...
// Schedule Pageview
if
(oLsched !=
null
&& (oLsched.Iltroom_Id > 0 || oLsched.Instruc_Id > 0))
{
// RadScheduler culture
DiaryRadScheduler.Culture =
new
System.Globalization.CultureInfo(sCulture);
// RadScheduler default date
DiaryRadScheduler.SelectedDate = DateTime.Now;
// RadScheduler fill
InitializeResources();
InitializeAppointments();
DiaryRadScheduler.DataSource = Appointments;
DiaryRadScheduler.DataBind();
}
...
#endregion Fill values
...
}
...
}
protected
void
Page_PreRender(
object
sender, EventArgs e)
{
...
if
(Appointments !=
null
)
ViewState[
"Appointments"
] = Appointments;
}
protected
void
BtnSubmit_Click(
object
sender, EventArgs e)
{
...
}
// Ajax request
public
void
PageRadAjaxManager_AjaxRequest(
object
sender, AjaxRequestEventArgs e)
{
bool
bRefreshLessonGrid =
false
;
bool
bRefreshDiary =
false
;
string
argument = (e.Argument);
string
[] argumentArray = argument.Split(
"|"
.ToCharArray(), StringSplitOptions.None);
...
string
sUpdateScript =
""
;
if
(bRefreshDiary && oLsched !=
null
)
{
//DiaryRadScheduler.Resources.Clear();
//DiaryRadScheduler.Appointments.Clear();
// RadScheduler fill
Appointments =
new
List<AppointmentInfo>();
InitializeResources();
InitializeAppointments();
DiaryRadScheduler.DataSource = Appointments;
DiaryRadScheduler.DataBind();
//sUpdateScript += "setTimeout(\"forceCalendarRender()\", 500);";
}
...
if
(!
string
.IsNullOrWhiteSpace(sUpdateScript))
ScriptManager.RegisterStartupScript(Page,
typeof
(Page),
"UpdateScript"
, sUpdateScript,
true
);
}
protected
void
DiaryRadScheduler_ResourceHeaderCreated(
object
sender, ResourceHeaderCreatedEventArgs e)
{
Panel HeaderLabelWrapper = e.Container.FindControl(
"HeaderLabelWrapper"
)
as
Panel;
if
(e.Container.Resource.Key.ToString() ==
"0"
)
HeaderLabelWrapper.CssClass =
"ResourceIlt"
;
else
if
(e.Container.Resource.Key.ToString() ==
"1"
)
HeaderLabelWrapper.CssClass =
"ResourceInstructor"
;
}
protected
void
DiaryRadScheduler_AppointmentDataBound(
object
sender, Telerik.Web.UI.SchedulerEventArgs e)
{
if
(e.Appointment.Resources.GetResourceByType(
"Type"
) !=
null
)
{
switch
((
int
)e.Appointment.Resources.GetResourceByType(
"Type"
).Key)
{
case
0:
e.Appointment.CssClass =
"rsCategoryILT"
;
break
;
case
1:
e.Appointment.CssClass =
"rsCategoryInstructor"
;
break
;
default
:
break
;
}
}
}
private
void
InitializeResources()
{
// 0 Room
// 1 Instructor
DiaryRadScheduler.ResourceTypes.Clear();
ResourceType resType =
new
ResourceType(
"Type"
);
resType.ForeignKeyField =
"Type"
;
DiaryRadScheduler.ResourceTypes.Add(resType);
DiaryRadScheduler.Resources.Clear();
//DiaryRadScheduler.Resources.Add(new Resource("Type", 0, oLoc.GetString("LblDiaryTypeRoom", oUser.Subdomain) + ((oLsched.Iltroom_Id > 0) ? " : " + LblIltRoomName.Text : "")));
DiaryRadScheduler.Resources.Add(
new
Resource(
"Type"
, 0, oLoc.GetString(
"LblDiaryTypeRoom"
, oUser.Subdomain) +
" : "
+ LblIltRoomName.Text));
//DiaryRadScheduler.Resources.Add(new Resource("Type", 1, oLoc.GetString("LblDiaryTypeInstructor", oUser.Subdomain) + ((oLsched.Instruc_Id > 0) ? " : " + LblInstructorName.Text : "")));
DiaryRadScheduler.Resources.Add(
new
Resource(
"Type"
, 1, oLoc.GetString(
"LblDiaryTypeInstructor"
, oUser.Subdomain) +
" : "
+ LblInstructorName.Text));
}
private
void
InitializeAppointments()
{
DiaryRadScheduler.Appointments.Clear();
// Display booking for the room
if
(oLsched.Iltroom_Id > 0)
{
DataSet dSchedule = Iltroom.GetIltroomScheduleDS(oLsched.Iltroom_Id, oUser.Lang_Id);
foreach
(DataRow mSchedule
in
dSchedule.Tables[
"Schedule"
].Rows)
{
#region Room
DateTime mTmpStartTime;
DateTime.TryParse(mSchedule[
"SCHSTART"
].ToString(),
out
mTmpStartTime);
DateTime mTmpEndTime;
DateTime.TryParse(mSchedule[
"SCHEND"
].ToString(),
out
mTmpEndTime);
string
mTmpCourse = mSchedule[
"COURSE_NAME"
].ToString();
string
mTmpCsExtid = mSchedule[
"CS_EXTID"
].ToString();
string
mTmpLesson = mSchedule[
"LESSON_NAME"
].ToString();
string
mTmpLsExtid = mSchedule[
"LS_EXTID"
].ToString();
string
mTmpInstructor = mSchedule[
"INSTRUCTOR"
].ToString();
if
(mTmpStartTime != DateTime.MinValue && mTmpStartTime !=
new
DateTime(1900, 1, 1) &&
mTmpEndTime != DateTime.MinValue && mTmpEndTime !=
new
DateTime(1900, 1, 1) &&
!
string
.IsNullOrWhiteSpace(mTmpCourse) && !
string
.IsNullOrWhiteSpace(mTmpLesson) &&
!
string
.IsNullOrWhiteSpace(mTmpCsExtid) && !
string
.IsNullOrWhiteSpace(mTmpLsExtid))
{
string
sSubject = oLoc.GetString(
"LblCourse"
, oUser.Subdomain) +
" : "
+ mTmpCourse + Environment.NewLine + mTmpCsExtid;
string
sDescription = oLoc.GetString(
"LblLesson"
, oUser.Subdomain) +
" : "
+ mTmpLesson + Environment.NewLine + mTmpLsExtid;
if
(!
string
.IsNullOrWhiteSpace(mTmpInstructor))
sDescription +=
"<br />"
+ oLoc.GetString(
"LblInstructor"
, oUser.Subdomain) +
" : "
+ mTmpInstructor;
Appointments.Add(
new
AppointmentInfo(sSubject, sDescription, mTmpStartTime, mTmpEndTime,
string
.Empty,
null
,
string
.Empty, 0));
}
#endregion Room
}
}
// Display booking for the instructor
if
(oLsched.Instruc_Id > 0)
{
DataSet dSchedule = Students.GetLschinstrucDS(oLsched.Instruc_Id, oUser.Lang_Id,
false
, DateTime.Now);
foreach
(DataRow mLschinstruc
in
dSchedule.Tables[
"Lschinstruc"
].Rows)
{
#region Instructor
DateTime mTmpStartTime;
DateTime.TryParse(mLschinstruc[
"SCHSTART"
].ToString(),
out
mTmpStartTime);
DateTime mTmpEndTime;
DateTime.TryParse(mLschinstruc[
"SCHEND"
].ToString(),
out
mTmpEndTime);
string
mTmpCourse = mLschinstruc[
"COURSE_NAME"
].ToString();
string
mTmpCsExtid = mLschinstruc[
"CS_EXTID"
].ToString();
string
mTmpLesson = mLschinstruc[
"LESSON_NAME"
].ToString();
string
mTmpLsExtid = mLschinstruc[
"LS_EXTID"
].ToString();
string
mTmpCenter = mLschinstruc[
"ILTLOC_NAME"
].ToString();
string
mTmpRoom = mLschinstruc[
"ILTROOM_NAME"
].ToString();
if
(mTmpStartTime != DateTime.MinValue && mTmpStartTime !=
new
DateTime(1900, 1, 1) &&
mTmpEndTime != DateTime.MinValue && mTmpEndTime !=
new
DateTime(1900, 1, 1) &&
!
string
.IsNullOrWhiteSpace(mTmpCourse) && !
string
.IsNullOrWhiteSpace(mTmpLesson) &&
!
string
.IsNullOrWhiteSpace(mTmpCsExtid) && !
string
.IsNullOrWhiteSpace(mTmpLsExtid))
{
string
sSubject = oLoc.GetString(
"LblCourse"
, oUser.Subdomain) +
" : "
+ mTmpCourse + Environment.NewLine + mTmpCsExtid;
string
sDescription = oLoc.GetString(
"LblLesson"
, oUser.Subdomain) +
" : "
+ mTmpLesson + Environment.NewLine + mTmpLsExtid;
if
(!
string
.IsNullOrWhiteSpace(mTmpCenter))
sDescription +=
"<br />"
+ oLoc.GetString(
"LblIltLocation"
, oUser.Subdomain) +
" : "
+ mTmpCenter;
if
(!
string
.IsNullOrWhiteSpace(mTmpRoom))
sDescription +=
"<br />"
+ oLoc.GetString(
"LblIltRoom"
, oUser.Subdomain) +
" : "
+ mTmpRoom;
Appointments.Add(
new
AppointmentInfo(sSubject, sDescription, mTmpStartTime, mTmpEndTime,
string
.Empty,
null
,
string
.Empty, 1));
}
#endregion Instructor
}
}
}
[Serializable]
class
AppointmentInfo
{
...
}
}
}
When debugging step by step, I update appointments list but it never appears correctly on client side
Moreover, if my appointment list is empty at first load, depending on my browser, the radscheduler is sometimes shrinked with a javascript error in the axd file..
If any one has a good idea....it would be greatly appreciated
Regards.