RadScheduler and RadTooltipManager not working together

1 posts, 0 answers
  1. Daniel Tharp
    Daniel Tharp avatar
    13 posts
    Member since:
    May 2006

    Posted 03 Feb 2011 Link to this post

    We just recently upgrade our control set and it seemed to have broke our implementation of using the radtooltipmanager with the radscheduler. I have been following the tutorial below and have created a test project that is the exact same and can't seem to get it working.

    http://demos.telerik.com/aspnet-ajax/scheduler/examples/radtooltip/defaultcs.aspx

    I took all the code from the demo page and put it into a test page. When the AjaxUpdate code runs as seen below, the FindByID returns a null. Also when I rollover the appointment the AppointmentCreated method gets called as well.

    Code-Behind
    private void Page_Load(object sender, EventArgs e)
        {
            RadScheduler1.AppointmentCreated += RadScheduler1_AppointmentCreated;
            RadScheduler1.DataBound += RadScheduler1_DataBound;
     
            this.RadScheduler1.DataSource = GetApps();
            this.RadScheduler1.DataBind();
        }
     
        private List<Appointment> GetApps()
        {
            List<Appointment> appList = new List<Appointment>();
     
            for (int i = 0; i < 10; i++)
            {
                Appointment app = new Appointment();
                app.ID = Guid.NewGuid();
                app.Subject = "Apt" + i.ToString();           
                app.Start = DateTime.Now.AddDays(i);
                app.End = DateTime.Now.AddDays(i).AddMinutes(30);
                appList.Add(app);
            }
     
            return appList;
        }
     
        protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            if (e.Appointment.Visible && !IsAppointmentRegisteredForTooltip(e.Appointment))
            {
                string id = e.Appointment.ID.ToString();
     
                foreach (string domElementID in e.Appointment.DomElements)
                {
                    RadToolTipManager1.TargetControls.Add(domElementID, id, true);
                }
            }
        }
     
        private bool IsAppointmentRegisteredForTooltip(Appointment apt)
        {
            foreach (ToolTipTargetControl targetControl in RadToolTipManager1.TargetControls)
            {
                if (apt.DomElements.Contains(targetControl.TargetControlID))
                {
                    return true;
                }
            }
     
            return false;
        }
     
        protected void RadScheduler1_DataBound(object sender, EventArgs e)
        {
            RadToolTipManager1.TargetControls.Clear();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "HideToolTip", "hideActiveToolTip();", true);
        }
     
        protected void RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
        {       
            Appointment apt = RadScheduler1.Appointments.FindByID(new Guid(e.Value));
             
            Portal_Controls_AppointmentToolTip toolTip = (Portal_Controls_AppointmentToolTip)LoadControl("Portal/Controls/AppointmentToolTip.ascx");
            toolTip.TargetAppointment = apt;
            e.UpdatePanel.ContentTemplateContainer.Controls.Add(toolTip);
        }

     


    html
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
    <%@ Reference Control="Portal/Controls/AppointmentToolTip.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <link rel="stylesheet" type="text/css" href="/Resources/css/styles.css" />
        <script language="javascript" src="/Resources/js/modals.js" type="text/javascript"></script>
        <script type="text/javascript">
            //<![CDATA[
            function hideActiveToolTip() {
                var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
                if (tooltip) {
                    tooltip.hide();
                }
            }
     
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandler);
            function beginRequestHandler(sender, args) {
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                if (args.get_postBackElement().id.indexOf('RadScheduler1') != -1) {
                    hideActiveToolTip();
                }
            }
     
            function clientBeforeShow(sender, eventArgs) {
                w = $telerik.$(window).width() / 2;
                h = $telerik.$(window).height() / 2;
     
                if ((sender._mouseX > w) && (sender._mouseY > h)) {
                    sender.set_position(Telerik.Web.UI.ToolTipPosition.TopLeft);
                    return;
                }
                if ((sender._mouseX < w) && (sender._mouseY > h)) {
                    sender.set_position(Telerik.Web.UI.ToolTipPosition.TopRight);
                    return;
                }
                if ((sender._mouseX > w) && (sender._mouseY < h)) {
                    sender.set_position(Telerik.Web.UI.ToolTipPosition.BottomLeft);
                    return;
                }
                sender.set_position(Telerik.Web.UI.ToolTipPosition.BottomRight);
            }
            //]]>
        </script>
    </head>
    <body id="body" runat="server" style="background-color:White;">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div style="padding:20px 20px 20px 20px;">
         
            <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                <ContentTemplate>
                    <telerik:RadScheduler runat="server"
                        ID="RadScheduler1"
                        Width="750px"
                        Height="600px"
                        TimeZoneOffset="03:00:00"                   
                        DayStartTime="08:00:00"
                        DayEndTime="18:00:00"
                        DataKeyField="ID"
                        DataSubjectField="Subject"
                        DataStartField="Start"
                        DataEndField="End"                   
                        DisplayDeleteConfirmation="false"
                        SelectedView="MonthView">
                        <AdvancedForm Modal="true" />
                        <TimelineView UserSelectable="false" />
                        <TimeSlotContextMenuSettings EnableDefault="true" />
                        <AppointmentContextMenuSettings EnableDefault="true" />
                    </telerik:RadScheduler>
                    <telerik:RadToolTipManager
                        runat="server"
                        ID="RadToolTipManager1"
                        Width="320"
                        Height="210"
                        Animation="None"
                        HideEvent="LeaveToolTip"
                        Text="Loading..."
                        RelativeTo="Element"
                        OnAjaxUpdate="RadToolTipManager1_AjaxUpdate"
                        OnClientBeforeShow="clientBeforeShow"
                        EnableShadow="true"/>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        </form>
    </body>
    </html>


    If you could point me in the right directory that would be great. I have attached the test file I have been working on.

    thanks
Back to Top