RadTooltip Auto Height Sizing

2 posts, 0 answers
  1. Craig
    Craig avatar
    12 posts
    Member since:
    Nov 2010

    Posted 28 Apr 2011 Link to this post


    I am using the RadTooltip in a RadTreeNode template to display data associated with each node in the tooltip. The length of the text will be different for each node. I am hoping to get the following behavior:

    • Be able to set a maximum height for the tooltip
    • Have the tooltip automatically size the height based on content unless that maximum height is exceeded.
    • If that height is exceeded, set the height of the tootip to the maximum and a add vertical scrollbar so all content can be scrolled to.


    Can you let me know if this is possible?

    Thanks, Craig

  2. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 02 May 2011 Link to this post

    Hello Craig,

     I already answered your support thread and for your convenience and for others who might have the same requirement, I pasted my reply below:

    The tooltip does not currently support the functionality you request out of the box but I added in our TODO list for consideration (this does not ensure that it will be added because this depends on the number of customer requests and to the priorities of tasks).

    For the time being I prepared for you the following script:

    Copy Code
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <script type="text/javascript">
    var maxHeight = 100;
    function OnClientShow(active) {
    setTimeout(function () {
    var height = active._tableElement.offsetHeight < maxHeight ? active._tableElement.offsetHeight : maxHeight;
    }, 0);
    function OnClientHide(active) {
    <telerik:RadToolTipManager ID="mng" runat="server" AutoTooltipify="true" ToolTipZoneID="tree"
    Position="MiddleRight" RelativeTo="Element" OnClientShow="OnClientShow" OnClientHide="OnClientHide"
    <telerik:RadTreeView ID="tree" runat="server">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test<br/>Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test<br/>Test<br/>Test<br/>Test">
    <telerik:RadTreeNode Text="Test" ToolTip="Test<br/>Test<br/>Test">

    Please, note, that this is the common case without Load On Demand used. If you are using Load On Demand, you should follow the same logic, but use the OnClientResponseEnd event instead of OnClientShow because the content is loaded at that time when on demand. In addition, if you use OnClientRespnseEnd you should reference the tooltip by using the getCurrent static method since the sender is the manager itself.

    I hope that the script I prepared for you is helpful as a base for implementing your requirement, let me know how it goes.

    Kind regards,
    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top