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

ToolTip/Calendar issue

2 Answers 69 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 09 Aug 2011, 04:15 PM
I'm adding a custom tooltip to "Special" events on the RadCalendar.  My code is below.

cell.Attributes.Add(

 

"id", "Calendar1_" + i.ToString());

 

RadToolTipManager1.TargetControls.Add(e.Cell.Attributes[

 

"id"], i.ToString(), true);

This works on the current month view.  So I'll hover and tooltip shows.....But when I add a future Event, I'll click on the next month link and it will show..ex. 9/9/2011....but when I hover all I get is a regular tooltip.
         Things I want to do:
                  1.  I want to load all my events info as the Page/Calendar loads.  I do not want to make an Ajax call.
                  2.  Tooltip doesnt seem to work on Weekends either, even on the current month....ex. 08/20/2011.....Any ideas?

Full Code:

 

 

 

protected void RadCalendar1_Load(object sender, EventArgs e)

 

{

 

 

RadCalendarDay calendarDay1 = new RadCalendarDay();

 

 

 

// calendarDay1.TemplateID = "EventTemplate";

 

 

 

 

 

calendarDay1.Date =

 

new DateTime(2011, 8, 19);

 

calendarDay1.ItemStyle.BorderColor = System.Drawing.

 

Color.Green;

 

calendarDay1.ItemStyle.BackColor = System.Drawing.

 

Color.Yellow;

 

 

 

 

 

RadCalendar1.SpecialDays.Add(calendarDay1);

 

 

 

 

 

 

 

RadCalendarDay calendarDay2 = new RadCalendarDay();

 

calendarDay2.Date =

 

new DateTime(2011, 9, 9);

 

 

 

 

 

calendarDay2.ItemStyle.CssClass =

 

"rcEvent";

 

 

 

 

 

calendarDay2.ToolTip =

 

"This is a test2<br/>Hello2";

 

RadCalendar1.SpecialDays.Add(calendarDay2);

 

 

RadCalendarDay calendarDay3 = new RadCalendarDay();

 

calendarDay3.Date =

 

new DateTime(2011, 8, 30);

 

calendarDay3.ItemStyle.BorderColor = System.Drawing.

 

Color.Green;

 

calendarDay3.ItemStyle.BackColor = System.Drawing.

 

Color.Yellow;

 

 

 

// calendarDay3.TemplateID = "EventTemplate";

 

 

 

 

 

RadCalendar1.SpecialDays.Add(calendarDay3);

 

 

RadCalendarDay calendarDay4 = new RadCalendarDay();

 

calendarDay4.Date =

 

new DateTime(2011, 3, 6);

 

calendarDay4.ItemStyle.BorderColor = System.Drawing.

 

Color.Green;

 

calendarDay4.ItemStyle.BackColor = System.Drawing.

 

Color.Yellow;

 

 

 

// calendarDay3.TemplateID = "EventTemplate";

 

 

 

 

 

RadCalendar1.SpecialDays.Add(calendarDay4);

 

 

RadCalendarDay calendarDay5 = new RadCalendarDay();

 

calendarDay5.Date =

 

new DateTime(2011, 12, 11);

 

calendarDay5.ItemStyle.BorderColor = System.Drawing.

 

Color.Green;

 

calendarDay5.ItemStyle.BackColor = System.Drawing.

 

Color.Yellow;

 

 

 

// calendarDay3.TemplateID = "EventTemplate";

 

 

 

 

 

RadCalendar1.SpecialDays.Add(calendarDay5);

}

 

 

protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)

 

{

 

 

Control ctrl = Page.LoadControl("ToolTip.ascx");

 

args.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl);

 

 

ToolTip details = (ToolTip)ctrl;

 

details.TestText = args.Value;

}

 

 

 

protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)

 

{

 

 

//string test = "Hello";

 

 

 

 

 

 

 

if (IsDayRegisteredForTooltip((e.Day.Date)))

 

{

 

 

TableCell cell = e.Cell;

 

 

 

// cell.CssClass = "Appointment";

 

 

 

 

 

 

 

string localTime = DateTime.Now.ToLocalTime().ToString();

 

 

 

//cell.Attributes.Add("id", "Calendar1_" + localTime);

 

 

 

 

 

 

 

//RadToolTipManager1.TargetControls.Add(e.Cell.Attributes["id"], localTime, true);

 

 

 

 

 

cell.Attributes.Add(

 

"id", "Calendar1_" + i.ToString());

 

RadToolTipManager1.TargetControls.Add(e.Cell.Attributes[

 

"id"], i.ToString(), true);

 

 

 

// RadToolTip1.Controls.Add(cell);

 

 

 

 

 

i++;

}

 

}

 

 

private bool IsDayRegisteredForTooltip(DateTime date)

 

{

 

 

if (date.ToShortDateString().Equals("8/30/2011") || date.ToShortDateString().Equals("9/9/2011"))

 

 

 

// if ( date.ToShortDateString().Equals("9/10/2011"))

 

 

 

 

 

{

 

 

return true;

 

}

 

 

else

 

 

 

 

 

{

 

 

return false;

 

}

}

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Aug 2011, 11:11 AM
Hello Shawn,

Please find attached my test project where I tried to recreate your setup. It seems to be working fine on my end, both for weekends and the next month. I used the ToolTip for RadCalendar demo as basis and you can do so as well, since the demos are installed in your RadControls folder under the LiveDemos directory. Thus you can freely examine and modify them.

The only major addition is the RadAjaxPanel and the functionality to page through the RadCalendar. This is necessary because the DayRender event is otherwise thrown only for the initial load, for the initial view. This is done do minimize the initial page load and reduce the amount of data that needs to be transferred. This is the reason why for other months you would need AJAX to add the tooltips and special days.

If you wish to avoid any round-trips to the server I can suggest that you use the client-side api of the ToolTipManager to tooltipitfy the calendar and the client-side events of the calendar to add the event to the cell that will need to show the tooltip. In essence both approaches are shown in the following demos:
examine the right-hand side calendar and tooltip manager here:
http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltipcalendar/defaultcs.aspx
and see how you can modify the cells on the client here:
http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/customdaycellrendering/defaultcs.aspx
and the available API for the RadCalendar here:
http://www.telerik.com/help/aspnet-ajax/calendar-client-side-rad-calendar.html



Kind regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Shawn
Top achievements
Rank 1
answered on 11 Aug 2011, 04:13 PM
Thanks for reply.  Not exactly what I was looking but it seems I will have to make a server call to reload each special day/event for that particular month the user has selected.  If with your client call it still doesnt work for September because the date is only loaded once.

thanks for info.
Tags
ToolTip
Asked by
Shawn
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Shawn
Top achievements
Rank 1
Share this question
or