I am using Rad Calendar with Rad Scheduler To Implement Events Like Outlook Calendar View .
I need Following Requirements ,Please Giude me .
1. On Click on Rad Scheduler Navigation , Need to Highlight Respective Day Or Week Or Month in Rad Calendar Based On Rad Scheduler View.
2.How to Use
telerik
:RadSchedulerRecurrenceEditor
For Implementing Custom Appointment Template.
3.How to Implement Go To Date Funtionality For Rad Calendar.
4.How to Navigate Rad Scheduler , on click of Rad Calendar Row Header -- > Month View Of rad Scheduler.
on Click of Rad Calendar Column Header -- > Week View of Rad Scheduler.
5. If Rad Scheduler is Day View Need to Display More Information.
If Rad Scheduler is Week View or Month View then Display Less Information.
6. Appointment Click event is not Working.( Need to Redirect to Different page)
Please Do the NeedFull.
Thanks.
10 Answers, 1 is accepted
Please, refer to this demo.
1. This requirement can be achieved with the following modifications to the demo:
private void Page_Load(object sender, EventArgs e)
{
checkBoxIDs = new Dictionary<
int
, string>();
checkBoxIDs.Add ( 1, "chkDevelopment" );
checkBoxIDs.Add ( 2, "chkMarketing" );
checkBoxIDs.Add ( 3, "chkQ1" );
checkBoxIDs.Add ( 4, "chkQ2" );
if (!IsPostBack)
{
RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
SyncCalendars();
}
RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
}
protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
{
RadCalendar1.FocusedDate = RadScheduler1.SelectedDate;
SyncCalendars();
RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
}
protected
void
RadCalendar1_DayRender(
object
sender, UI.Calendar.DayRenderEventArgs e)
{
if
((RadScheduler1.VisibleRangeStart <= e.Day.Date) & (e.Day.Date <= RadScheduler1.VisibleRangeEnd))
e.Cell.CssClass =
"Custom"
;
}
.Custom
{
background
: yellow
!important
;
}
<
telerik:AjaxSetting
AjaxControlID
=
"RadScheduler1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadScheduler1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadCalendar1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
2. You can integrate the recurrence editor in an appointment template like so:
<
AppointmentTemplate
>
<
div
class
=
"rsAptSubject"
>
<%# Eval("Subject") %>
</
div
>
<%# Eval("Description") %>
<
telerik:RadSchedulerRecurrenceEditor
ID
=
"RadSchedulerRecurrenceEditor1"
runat
=
"server"
>
</
telerik:RadSchedulerRecurrenceEditor
>
</
AppointmentTemplate
>
protected
void
RadScheduler1_AppointmentCreated(
object
sender, AppointmentCreatedEventArgs e)
{
RadSchedulerRecurrenceEditor recEditor1 = e.Container.FindControl(
"RadSchedulerRecurrenceEditor1"
)
as
RadSchedulerRecurrenceEditor;
recEditor1.RecurrenceRuleText = e.Appointment.RecurrenceRule;
}
3. Please, see this demo.
4. This functionality is demonstrated in the First look example I already refered you to.
5. You can create appointment templates dynamically for each view as shown in this kb article.
6. We are not aware of any issues with the AppointmentClick event. If you need to redirect, you can insert a hyperlink in the AppointmentTemplate.
I hope this helps.
Greetings,
Peter
the Telerik team
I am unable to Meet the Requirement After Modifications Happened in Demo Code.
on RadSchduler Navigation i need to highlight Calendar Dates based on Rad Scheduler View ( Day OR Week OR Month).
Please Find the screen Shots.
Following is Code
using
System;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
System.Data;
using
System.Data.SqlClient;
using
Telerik.Web.UI.Calendar;
using
System.Collections.Generic;
public
partial class RadCal : System.Web.UI.Page
{
private void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fnGetEvents();
RadScheduler1.DataSource = (
DataSet)Session["ApptDs"];
RadScheduler1.DataKeyField =
"EventId";
RadScheduler1.DataStartField =
"Start";
RadScheduler1.DataEndField =
"End";
RadScheduler1.DataSubjectField =
"Subject";
RadScheduler1.TimeZoneOffset =
new TimeSpan(0, 0, 0);
RadScheduler1.SelectedDate = System.
DateTime.Now.Date;
}
RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
DataSet objDataset = new DataSet();
objDataset = (
DataSet)Session["ApptDs"];
DateTime calDate;
String evTitle = string.Empty;
if (objDataset.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < objDataset.Tables[0].Rows.Count; i++)
{
calDate = (
DateTime)objDataset.Tables[0].Rows[i].ItemArray[1];
evTitle = objDataset.Tables[0].Rows[i].ItemArray[4].ToString();
RadCalendarDay newDay = new RadCalendarDay(RadCalendar1);
newDay.Date =
new DateTime(calDate.Year, calDate.Month, calDate.Day);
newDay.Repeatable = Telerik.Web.UI.Calendar.
RecurringEvents.None ;
newDay.TemplateID =
"dayTemplate1";
newDay.ItemStyle.BackColor = System.Drawing.
Color.Bisque ;
newDay.ToolTip = evTitle;
RadCalendar1.SpecialDays.Add(newDay);
}
}
}
protected void RadCalendar1_SelectionChanged(object sender, SelectedDatesEventArgs e)
{
if (RadCalendar1.SelectedDates.Count > 0)
{
RadScheduler1.SelectedDate = RadCalendar1.SelectedDate;
}
}
protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
e.Appointment.BackColor = System.Drawing.
Color.Yellow;
e.Appointment.BorderColor = System.Drawing.
Color.Red;
e.Appointment.BorderStyle =
BorderStyle.Dotted;
e.Appointment.ToolTip =
"Double Click here to See Details.";
}
protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
{
//RadCalendar1.SpecialDays.Clear();
//DataSet objDs = new DataSet();
//objDs = (DataSet )Session["ApptDs"];
RadScheduler1.Rebind();
}
protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
{
//RadCalendar1.SpecialDays.Clear();
//RadCalendarDay newDay = new RadCalendarDay(RadCalendar1);
//newDay.Date = new DateTime(this.RadScheduler1.SelectedDate.Year, this.RadScheduler1.SelectedDate.Month, this.RadScheduler1.SelectedDate.Day);
//newDay.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.None;
//newDay.TemplateID = "dayTemplate1";
//newDay.ItemStyle.BackColor = System.Drawing.Color.BlueViolet;
//newDay.ToolTip = "aaa";
//RadCalendar1.SpecialDays.Add(newDay);
//RadCalendar1.SpecialDays[0].Date = this.RadScheduler1.SelectedDate;
//RadCalendar1.SpecialDays[0].Repeatable = RecurringEvents.None;
//if (e.Command == SchedulerNavigationCommand.SwitchToDayView)
//{
// Label lbl = (Label)this.RadScheduler1.FindControl("lblEventId");
//}
RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
}
protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)
{
Response.Redirect(
"RadSchDtls.aspx?id="+e.Appointment .ID );
}
//protected void RadScheduler1_PreRender(object sender, EventArgs e)
//{
// RadCalendar popupCalendar = RadScheduler1.FindControl("SelectedDateCalendar") as RadCalendar;
//}
private void fnGetEvents()
{
DataSet objDs = new DataSet();
DataTable objDt = new DataTable();
objDt.Columns.Add(
"EventId", typeof(string));
objDt.Columns.Add(
"Start", typeof(DateTime));
objDt.Columns.Add(
"End", typeof(DateTime));
objDt.Columns.Add(
"Temp", typeof(DateTime));
objDt.Columns.Add(
"Subject", typeof(string));
objDt.Columns.Add(
"Description", typeof(string));
for (int i = 1; i < 23; i++)
{
DataRow objDr = objDt.NewRow();
DateTime objdate = new DateTime(2010, 08, 05, 09, 40, 00);
objDr[
"EventId"] = i.ToString ();
objDr[
"Start"] = objdate.AddDays (0).AddHours (0+i);
objDr[
"End"] = objdate.AddDays(0).AddHours (0+i+1);
objDr[
"Temp"] = objdate.AddDays(0).Date.ToShortDateString();
objDr[
"Subject"] = "Subject"+i.ToString ();
objDr[
"Description"] = "Description"+i.ToString ();
objDt.Rows.Add(objDr);
}
DataRow objDr1 = objDt.NewRow();
DateTime objdate1 = new DateTime(2010, 08, 07, 09, 40, 00);
objDr1[
"EventId"] = 11.ToString();
objDr1[
"Start"] = objdate1.AddDays(1).AddMinutes(1 + 5);
objDr1[
"End"] = objdate1.AddDays(1).AddDays(14);
objDr1[
"Temp"] = objdate1.AddDays(1).Date.ToShortDateString();
objDr1[
"Subject"] = "Subject" + 11.ToString();
objDr1[
"Description"] = "Description" + 11.ToString();
objDt.Rows.Add(objDr1);
objDs.Tables.Add(objDt);
Session[
"ApptDs"] = objDs;
}
protected void cmdDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
{
String renderedDay = e.Day.Date.AddDays(1).Day.ToString();
DayTemplate myTemplate = new DayTemplate();
myTemplate = RadCalendar1.CalendarDayTemplates[
"dayTemplate1"];
if (myTemplate != null)
{
foreach (Control ctr in RadCalendar1.Controls)
{
DataSet objds = (DataSet)Session["ApptDs"];
String str = e.Day.Date.AddDays(1).Date.ToShortDateString();
string strExpr = "Temp ='" + str + "'";
DataRow[] fndRows = objds.Tables[0].Select(strExpr);
HyperLink myLink = new HyperLink();
myLink = (
HyperLink)ctr.FindControl("lnkEvent");
int ii = fndRows.Length;
if (fndRows.Length == 0)
{
myLink.Text = renderedDay;
}
else
{
myLink.Text = renderedDay +
"(" + fndRows.Length.ToString() + ")";
}
}
}
}
protected void RadCalendar1_DefaultViewChanged(object sender, DefaultViewChangedEventArgs e)
{
RadScheduler1.SelectedDate =
new DateTime(e.NewView.NextView.ViewStartDate.Year, e.NewView.NextView.ViewStartDate.Month, 1);
}
}
And I need to Display Count in Rad Calendar.
Thanks & Regards.
Here is my test page which works as per your requirement. Please, replace your original page in the Outlook 2007 RadScheduler demo of your local installation of the controls and test it. Can you make sure you have defined your Custom style for the RadCalendar days. To be sure that this is not just a css issue, you can examine the rendered html and check if the 'Custom' class has applied to the days of the calendar for the current view of RadScheduler.
Best wishes,
Peter
the Telerik team
I Have Another Requirement that ,
In RadScheduler, i need to show Appointments .
Based on DataBase value need to Change Background Color to Appointments .
Is it Possible ?
And I need to Find Contorl inside Appointment template.
You can set the BackColor property conditionally in AppointmentDataBound:
protected
void
RadScheduler1_AppointmentDataBound(
object
sender, SchedulerEventArgs e)
{
if
(
MyCustomCondition
)
{
e.Appointment.BackColor = System.Drawing.Color.Green;
}
}
To keep the rounded corners and gradient of the appointments, set AppointmentStyleMode="Default" for RadScheduler.
You can find controls inside AppointmentTemplate by handling AppointmentCreated like this:
<
AppointmentTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
"Label"
></
asp:Label
>
</
AppointmentTemplate
>
protected
void
RadScheduler1_AppointmentCreated(
object
sender, AppointmentCreatedEventArgs e)
{
Label subject = e.Container.FindControl(
"Label1"
)
as
Label;
subject.Text = e.Appointment.Subject +
" (modified)"
;
}
Best wishes,
Peter
the Telerik team
example:
div class="clasename"
<%# Eval("casenumber") %>
/div
One and convenient way to achieve the described scenario would be to use Custom Attributes. Please follow this demo which is showing how you can use custom attributes and apply them to the appointment template.
Regards,
Boyan Dimitrov
the Telerik team
One way to achieve that functionality would be to use the AppointmentCreated server-side event handler to add a literal control to your appointment with value from your data set.
//markup code
<
telerik:RadScheduler
ID
=
"RadScheduler1"
runat
=
"server"
OnAppointmentCreated
=
"RadScheduler1_AppointmentCreated"
>
</
telerik:RadScheduler
>
//code behind
protected
void
RadScheduler1_AppointmentCreated(
object
sender, AppointmentCreatedEventArgs e)
{
Literal textBox =
new
Literal();
textBox.Text =
"sample value"
;
e.Container.Controls.Add(textBox);
}
Regards,
Boyan Dimitrov
the Telerik team