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

radgrid gridhyperlinkcolumn tooltip with newline

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susan Hessler
Top achievements
Rank 1
Susan Hessler asked on 04 Nov 2015, 08:57 PM

Using vb.net....  I have a radgrid with a gridhypercolumn.  I have added a tool tip in the ItemDataBound subroutine.  I am grabbing the tooltip text from a field in the database.  I cannot figure out what character(s) I need to put in the string so that I can display "Line one. <br \> Line two. \n Line three. &#013;" like:

Line one.

Line two.

Line three.

 

I have tried <br \>, \n, &#013;.  I have even set the tooltip to "eval('"Line one. <br \> Line two. \n Line three. &#013;")" with no luck.

 

I also have the following in the style tags:

.tooltip-inner {

         white-space: pre-wrap;

}

 

Thanks,

Susan

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Nov 2015, 08:24 AM

Hi Susan,

RadToolTip uses HTML, so the line separator would be <br />

How this is to be stored in your database, however, is up to the concrete case (e.g., you may need to encode the HTML string before storing and decode it after storing, depending on your DB setup).

Let's take the following demo for an example: http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=tooltip. Here is how it can be modified to show simple HTML (I am pasting only the changed code):

private void UpdateToolTip(string elementID, UpdatePanel panel)
{
    string content = string.Format("<div class=\"tooltip-inner\">line one {0}<br />Second line {0}<br />Line 3: {0}</div>", elementID);
    panel.ContentTemplateContainer.Controls.Add(new LiteralControl(content));
    //Control ctrl = Page.LoadControl("ProductDetailsCS.ascx");
    //ctrl.ID = "UcProductDetails1";
    //panel.ContentTemplateContainer.Controls.Add(ctrl);
    //ProductDetailsCS details = (ProductDetailsCS)ctrl;
    //details.ProductID = elementID;
}

To make the example simple, I am using a literal to add HTML directly, instead of using a user control.

If you find it easier, however, you can create your layout (including the line breaks) in the user control and populate it with data as shown in the demo.

If I am mistaken and you actually use the ToolTip server property of the HyperLink control, the line separator is \n for the browser tooltips. Here is an example (based on this demo again, but uses browser tooltips and not RadToolTips):

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
    {
        Control target = e.Item.FindControl("targetControl");
        if (!Object.Equals(target, null))
        {
            (target as HyperLink).ToolTip = string.Format("Line one: {0}\nSecond line: {0}\nLine 3: {0}", (e.Item as GridDataItem).GetDataKeyValue("ProductID").ToString());
        }
    }
}


Regards,

Marin Bratanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Susan Hessler
Top achievements
Rank 1
answered on 06 Nov 2015, 08:12 PM

I use this data in more than one place so...  In the database, I have <br />, which works everywhere except the tooltip.  To get it to work in the tooltip, I replaced all "<br />" with vbNewLine and it works! 

 Thanks!

Tags
Grid
Asked by
Susan Hessler
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Susan Hessler
Top achievements
Rank 1
Share this question
or