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

RadTooltip issue

7 Answers 248 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
eric knight
Top achievements
Rank 1
eric knight asked on 02 Apr 2008, 11:40 PM
Hello,

I am attempting to display appoinment information in a radtooltip and am running into a strange problem.

First off, I am using the Scheduler's AppointmentCreated event to dynamically create the tooltips:
    protected void Scheduler_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)  
    {  
        RadToolTip tooltip = new RadToolTip();  
        tooltip.ID = "tooltip";  
        tooltip.TargetControlID = e.Appointment.ClientID;  
        tooltip.IsClientID = true;  
        tooltip.Animation = ToolTipAnimation.Resize;  
        tooltip.Sticky = true;  
        tooltip.ContentScrolling = ToolTipScrolling.Auto;  
        tooltip.RelativeTo = ToolTipRelativeDisplay.Mouse;  
 
        StringBuilder sb = new StringBuilder();  
        sb.AppendFormat(e.Appointment.Subject);  
        sb.Append(" ");  
        sb.AppendFormat("{0}{1}{2}", e.Appointment.Start.ToShortTimeString(), " - ",  
            e.Appointment.End.ToShortTimeString());  
 
        e.Appointment.ToolTip = string.Empty;  
 
        tooltip.Text = "Something wonderful!";  
          
        e.Container.Controls.Add(tooltip);        
          
    } 

Nothing to fancy here and everything at this point works like a charm.

The problem starts when I start adding controls to the tooltip control collection:

    protected void Scheduler_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)  
    {  
        RadToolTip tooltip = new RadToolTip();  
        tooltip.ID = "tooltip";  
        tooltip.TargetControlID = e.Appointment.ClientID;  
        tooltip.IsClientID = true;  
        tooltip.Animation = ToolTipAnimation.Resize;  
        tooltip.Sticky = true;  
        tooltip.ContentScrolling = ToolTipScrolling.Auto;  
        tooltip.RelativeTo = ToolTipRelativeDisplay.Mouse;  
 
        StringBuilder sb = new StringBuilder();  
        sb.AppendFormat(e.Appointment.Subject);  
        sb.Append(" ");  
        sb.AppendFormat("{0}{1}{2}", e.Appointment.Start.ToShortTimeString(), " - ",  
            e.Appointment.End.ToShortTimeString());  
 
        e.Appointment.ToolTip = string.Empty;  
 

        Button button = new Button();  

        button.ID = "btnA";  

        button.Text = "Button in a ToolTip";  

        tooltip.Controls.Add(button);  

          
        e.Container.Controls.Add(tooltip);        
          
    } 

Basically, when I start adding controls to the tooltip control collection, instead of poping up normally, the tooltip pops up inside what I believe is the appointment container (appointment div?). If I knew how to attach files I would include a screenshot of what I am talking about.

Please let me know what you find. Also, please provide me with a server side solution as this simple example is only the tip of the iceberg of what I need to do.

If you need more information I will try to provide a better description of the problem.

Thank you.

7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 03 Apr 2008, 02:06 PM
Hi Eric,

The scenario which you want to implement is supported by RadTooltip, however you have to follow the approach from this online example and use an Update panel. Let us know how it goes.


Kind regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
eric knight
Top achievements
Rank 1
answered on 03 Apr 2008, 05:38 PM
Hello Peter,

Thank you for the suggestion. The tooltip is displaying properly now.

The problem I have at this point is now I'm unsure of how to access the Scheduler Appointment information in the AjaxUpdate event

Here is my aspx code:

                        <asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional">  
                                <contenttemplate> 
                                    <telerik:radscheduler id="schCalendar" runat="server" datakeyfield="ID" datasubjectfield="Title" 
                                        datastartfield="StartDTm" dataendfield="EndDTm" datarecurrencefield="RecurrencePattern" 
                                        datarecurrenceparentkeyfield="RecurringParentID" enableembeddedskins="false" overflowbehavior="Expand" 
                                        monthvisibleappointmentsperday="4" onnavigationcomplete="Scheduler_NavigationComplete" 
                                        onclientrecurrenceactiondialogshowing="OnClientRecurrenceActionDialogShowing"   
                                        onformcreated="Scheduler_FormCreated" onappointmentinsert="Scheduler_AppointmentInsert" 
                                        onappointmentcommand="Scheduler_AppointmentCommand" onappointmentdelete="Scheduler_AppointmentDelete" 
                                        onappointmentupdate="Scheduler_AppointmentUpdate" onappointmentdatabound="Scheduler_AppointmentDataBound" 
                                        onappointmentcreated="Scheduler_AppointmentCreated" enableviewstate="true">  
                                    </telerik:radscheduler>                                                                   
                                    <telerik:radtooltipmanager id="RadToolTipManager1" runat="server"   
                                        onajaxupdate="RadToolTipManager1_AjaxUpdate" 
                                        relativeto="Mouse" 
                                        width="310px" 
                                        height="250px" 
                                        position="BottomLeft" 
                                        sticky="true"                                         
                                        skin="WebBlue" 
                                        showevent="OnMouseOver">  
                                    </telerik:radtooltipmanager> 
                                </contenttemplate> 
                            </asp:updatepanel>   

And in code behind I have:

    protected void RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)  
    {  
        e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("Some profound, world changing text here..."));                        
    } 

My initial thought was to use the Scheduler's Appointment Created event to assign the target controls:

    protected void Scheduler_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)  
    {  
        RadToolTipManager1.TargetControls.Add(e.Appointment.ClientID, true);  
    } 

I don't know, maybe this is the correct way to do things, but from here I don't believe that the ToolTipUpdateEventArgs has the Appointment data?

So to simplify, I need to be able to get at the Appointment information from the AjaxUpdate event.

Thanks.
0
Peter
Telerik team
answered on 04 Apr 2008, 12:27 PM
Hello eric,

Ah yes, very good point indeed. Here is one possible solution:
protected void RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)  
    {  
        e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("Start Time: " + e.Value.Split('_')[1] + "</br> Subject: " + e.Value.Split('_')[0]));  
          
    }  
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)  
    {  
        string appInfo = e.Appointment.Subject + "_" + e.Appointment.Start.ToString();  
        RadToolTipManager1.TargetControls.Add(e.Appointment.ClientID, appInfo, true);  
    } 

The Add method of TargetControls has an overload in which the second pareameter is of type string and can carry information in the AjaxUpdate event accessed via e.Value.

Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
eric knight
Top achievements
Rank 1
answered on 04 Apr 2008, 04:38 PM
Hello Peter,

Thank you for the reply. Looks like we are both on the same track.

My initial thought on this was to try and serialize the appointment object (using XmlSerializer) and passing the string into the TargetControls.Add method, but ran into a problem (error reflecting type Telerik.Web.UI.Appointment).

I still liked the idea, so next I created a custom Appointment struct, filled the struct with the Appointment object data and attempted to repeat the same process. This time I had no problem with the serialization, but loading the data into the TargetControls.Add must have interferred with the Scheduler javascript as I received an error (javascript error: Line:1963 Error: Expected '}'.

I still really like this solution, and might continue to persue it, but of the time being I've shelved it.

Finally, I tried the suggestion you provided, but now I am getting a different javascript error (Microsoft JScript compilation error: Expected ']').
In debug mode, all I can tell is that it is coming from this line:
this._targetControls=eval(_44); 

I initially thought it had something to do with the split charatcer '_', so I replaced it with '|', however this didn't make any difference.

I guess worst case senario, I can pass the Appointment ID into TargetControls.Add and then reload the data in AjaxUpdate, but since I already have the data I would perfer not to do that.

If you guys have any other suggestions I am definitely open to ideas.

Also, as a feature request, maybe in the future you could provide another overload to the TargetControls.Add method to include an object param.

Thanks again!
0
Accepted
Peter
Telerik team
answered on 07 Apr 2008, 12:48 PM
Hi Eric,

I see you have attempted a more elegant solution. I also initially considered suggesting you to use the approach from the Load on Demand example with RadTooltip as that would be a more mainstream solution. However, when I examined this example closer I didn't like the complexity of it, so I decided to try something simpler. You can also take a look at this example and decide if this is something you want to utilize.

I am not sure why you experienced these problems. I can send you a working demo project if you think that could provide with clues. Or, you can open a support ticket and send us a project yourself so we can take a look at it.


Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
eric knight
Top achievements
Rank 1
answered on 07 Apr 2008, 03:35 PM
Good Morning Peter,

If you have a working demo I would love to see it. For now I have resorted to taking the ApointmentID approach but would definately like to see what you came up with.

Also, as the AppointmentID approach is a workable solution you can consider this item closed.

Thank you again for your efforts!
0
Peter
Telerik team
answered on 09 Apr 2008, 01:01 PM

Thank you Erick. Currently, I don't have a working solution, but it is possible that we make a KB article or a code library project about this case. If we do, I will notify you.  


Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
eric knight
Top achievements
Rank 1
Answers by
Peter
Telerik team
eric knight
Top achievements
Rank 1
Share this question
or