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

Error in RadManager Tool Tip

1 Answer 53 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Janni
Top achievements
Rank 1
Janni asked on 15 Sep 2010, 01:16 PM
Hi Team,
 
I've implemented the RadManager Tool Tip by the guide of this  http://demos.telerik.com/aspnet-ajax/scheduler/examples/radtooltip/defaultcs.aspx example.
 
I've implemented completely whatever you defined in that example.
 
Below is my code.
 
aspx page:
 
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Width="100%" runat="server"
        Skin="WebBlue">
    </telerik:RadAjaxLoadingPanel>
    <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
        <ContentTemplate>
            <div style="width: 803px; background: transparent url('Images/background.png') no-repeat 0 0;
                padding-left: 20px;">
                <telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Web20" CustomAttributeNames="StartTime,EndTime,SessionDate,DisplayPermitName,EventStartDate,DisplayClientTypeVisibility,DisplayResourceVisibility,DisplayFacilityVisibility,EventEndDate,ID,DisplayPermitVisibility,DisplayFacilityName,DisplayResourceName,DisplayClientTypeName,Event_ID"
                    SelectedDate="2010-08-10" DataStartField="EventStartDate" on EnableDatePicker="true"
                    GroupingDirection="Horizontal" MonthView-GroupingDirection="Horizontal" DataEndField="EventEndDate"
                    DayStartTime="08:00:00" DayEndTime="23:00:00" ShowFullTime="true" DataKeyField="ID"
                    FirstDayOfWeek="Monday" LastDayOfWeek="Friday" DataSubjectField="DisplayPermitName"
                    EnableEmbeddedSkins="false" AllowDelete="false" AllowEdit="false" TimelineView-NumberOfSlots="4"
                    AllowInsert="false" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
                    OnDataBound="RadScheduler1_OnDataBound" >
                    <AdvancedForm Modal="true" />
                    <AppointmentTemplate>
                        <%--Permit Name--%>
                        <asp:LinkButton runat="server" ID="lblDisplayPermitName" OnClick="RedirectToEventMaintenance"
                            Style="font-weight: bold; color: HighlightText; font-size: 14px;" CommandArgument='<%# Eval("Event_ID") + "~" + Eval("SessionDate") %>'
                            Visible='<%# Convert.ToBoolean(Eval("DisplayPermitVisibility")) %>'>
                        <%# Eval("DisplayPermitName")%>
                        </asp:LinkButton><br />
                        <%--Start Time--%>
                        <%--End Time--%>
                        <%# Eval("StartTime")%>
                        -
                        <%# Eval("EndTime")%>
                        <br />
                        <%--ClientType Name--%>
                        <asp:Label runat="server" ID="lblDisplayClientTypeName" Text="ClientType Name :"
                            Visible='<%# Convert.ToBoolean(Eval("DisplayClientTypeVisibility")) %>'>
                            <%# Eval("DisplayClientTypeName")%>
                        </asp:Label><br />
                        <%--Facility Name--%>
                        <asp:Label runat="server" ID="lblDisplayFacilityName" Text="Facility Type Name :"
                            Visible='<%# Convert.ToBoolean(Eval("DisplayFacilityVisibility")) %>'>
                    <%# Eval("DisplayFacilityName")%>
                        </asp:Label>
                        <br />
                        <%--Resource Name--%>
                        <asp:Label runat="server" ID="lblDisplayResourceName" Text="Resource Name :" Visible='<%# Convert.ToBoolean(Eval("DisplayResourceVisibility")) %>'>
                            <%# Eval("DisplayResourceName")%>
                        </asp:Label><br />
                    </AppointmentTemplate>
                </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>
  <telerik:RadCodeBlock ID="radCodeBlock1" runat="server">
 
        <script type="text/javascript">
            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>
 
    </telerik:RadCodeBlock>
 
.cs file
---------
 
 
        #region Scheduler Events
        /// <summary>
        /// RadScheduler1_AppointmentDataBound
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RadScheduler1_AppointmentDataBound(object sender, Telerik.Web.UI.SchedulerEventArgs e)
        {
            var schedulesGroupsSubjects = (from schdules in AdminController.State.Session.Schedules
 
                                           group schdules by schdules.DisplayPermitName);
            int count = schedulesGroupsSubjects.ToArray().Count();
            for (int i = 0; i < count; i++)
            {
                //    Random random = new Random();
                //    Color[] randomColor = new Color[count];
                //    randomColor[i] = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));
                //    string[] color = new string[count];
                //    color[i]=(new Random()).Next(0xffffff).ToString("x6");
 
                string[] strColor = new string[]{"rsCategoryDarkBlue", "rsCategoryBlue", "rsCategoryDarkGreen", "rsCategoryGreen", "rsCategoryDarkRed",
                    "rsCategoryOrange", "rsCategoryPink", "rsCategoryRed", "rsCategoryViolet", "rsCategoryYellow"};
                // strColor[i] = new Random().Next(strColor[i]).ToString();
                var schedulevar = schedulesGroupsSubjects.ToArray()[i].ToList<Schedule>();
                IList<Schedule> schNew = schedulevar.ToList<Schedule>();
 
                for (int j = 0; j < schNew.Count; j++)
                {
                    if (e.Appointment.Subject == schNew[j].DisplayPermitName)
                        e.Appointment.CssClass = strColor[i].ToString();
                }
            }
 
        }
        /// <summary>
        /// RadScheduler1_OnDataBound
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RadScheduler1_OnDataBound(object sender, EventArgs e)
        {
            if (RadScheduler1.SelectedView == SchedulerViewType.MonthView)
                RadScheduler1.ShowHoursColumn = false;
            else if (RadScheduler1.SelectedView == SchedulerViewType.WeekView)
                RadScheduler1.ShowHoursColumn = false;
            else
                RadScheduler1.ShowHoursColumn = true;
 
            RadToolTipManager1.TargetControls.Clear();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "HideToolTip", "hideActiveToolTip();", true);
        }
        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 RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
        {
            int aptId;
            Appointment apt;
            if (!int.TryParse(e.Value, out aptId))//The appoitnment is occurrence and FindByID expects a string
            {
                apt = RadScheduler1.Appointments.FindByID(e.Value);
                if(apt == null)
                    apt = RadScheduler1.Appointments.FindByID(aptId);
            }
            else //The appointment is not occurrence and FindByID expects an int
 
                apt = RadScheduler1.Appointments.FindByID(aptId);
 
            AppointmentToolTip toolTip = (AppointmentToolTip)LoadControl("~/UserControls/AppointmentToolTip.ascx");
            toolTip.TargetAppointment = apt;
            e.UpdatePanel.ContentTemplateContainer.Controls.Add(toolTip);
        }
        #endregion    
 
I got null value in "apt" of RadToolTipManager1_AjaxUpdate()
so exception raised in this page and appointmenttooltip.ascx page too
 
can some one help me out.....
 
Thanks,
Daniel.B

1 Answer, 1 is accepted

Sort by
0
Janni
Top achievements
Rank 1
answered on 17 Sep 2010, 11:05 AM
Hi Team,

I got the answer.
Just by split the rad scheduler value and passed to the tooltip.appointment.

Thanks
Tags
Scheduler
Asked by
Janni
Top achievements
Rank 1
Answers by
Janni
Top achievements
Rank 1
Share this question
or