RadToolTip not showing on RadGrid field?

3 posts, 0 answers
  1. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 06 Jul 2011 Link to this post

    I have a RadGrid where I'm truncating the display of cell data in order to preserve page real estate.  I want to show the full cell content in a RadToolTip.

    On the server, in the GridItemDataBound server-side event handler, I'm transforming the values of each cell for display.  On the client, I'm truncating the display data using text-overflow:ellipsis.  On the server, I'm creating a RadToolTip with the full value, and shoving it into the Page object's Controls collection:

    var item = (GridDataItem)e.Item;
    var cell = item["Flavor"];
    cell.Text = reallyLongFlavorNameValue;

    var tooltip = new RadToolTip();
    tooltip.Title = "Flavor";
    tooltip.Text = reallyLongFlavorNameValue;
    tooltip.TargetControlID = cell.ID;
    tooltip.IsClientID = false;
    tooltip.RelativeTo = ToolTipRelativeDisplay.Element;

    I'm assuming the rest of the values can be defaults.

    However, when I show the page, the tooltip never shows. 

    What am I missing?

  2. Marin Bratanov
    Marin Bratanov avatar
    3908 posts

    Posted 07 Jul 2011 Link to this post

    Hi Mike,

      I am not sure how and why you add a control (the tooltip) to the controls collection, but I would advise against this. This is a databound event and it is a bit too late in the page lifecycle to add controls. Besides, after a few ajaxified pagings of the grid you would end up with several tooltips for the same cell, which may result in an unexpected behavior and would weigh down the markup.

    What I would suggest is that you use the RadToolTipManager instead, add the cell to its target controls collection and use it to display the value. For more information on this approach please examine the following online demo: http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=grid. For the difference between the RadToolTip and the RadToolTipManager please examine this one: http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltipversustooltipmanager/defaultcs.aspx.

      For your convenience I created and attached a simple page that illustrates the approach. You can find a video with the expected behavior in the following link: http://screencast.com/t/4Zmyx0RWay. Please note how the cells have different content, yet their IDs remain the same.

    All the best,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 07 Jul 2011 Link to this post

    I was adding the tooltip to the Page's Controls collection because it wasn't clear from the documentation where to add them, and I found some online posts by others saying to do so.

    I actually solved this myself, yesterday.  The trick apears to be using GridTemplateColumns and adding the tooltips to the ItemTemplate.  It took some refactoring, but I was able to get it to work.

    I'm not sure that I need to move to the RadToolTipManager.  If I need to do that, I will definitely try your suggestion.

Back to Top