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

Display large text field column in tooltip

4 Answers 478 Views
Grid
This is a migrated thread and some comments may be shown as answers.
johnathan
Top achievements
Rank 1
johnathan asked on 13 Jan 2009, 07:51 AM
are there any examples of how to display a large text field in a tooltip. I have a column on my grid that is truncated and on mouse over I would like the tooltip to display the text. The column is a htmleditcolumn which has no ID field, just a unique name field. i looked through the samples, but they provide much more elaborate scenarios than I have, thanks

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Jan 2009, 10:54 AM
Hello Jonathan,

You can try out the following code to display a tooltip on hovering over the cells in a particular column.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" Width="1000"  DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid1_ItemDataBound" >            
     <MasterTableView DataKeyNames="ContactName" DataSourceID="SqlDataSource1" > 
               

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
 
        if (e.Item is GridDataItem) 
        { 
           GridDataItem dataItem = (GridDataItem)e.Item; 
           string strtxt = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ContactName"].ToString();  
           dataItem["ContactName"].ToolTip = strtxt
        }   
    } 
 

Thanks
Princy.
0
Dimo
Telerik team
answered on 13 Jan 2009, 03:20 PM
Hello Jonathan,

Unfortunately, the size of system browser tooltips cannot be controlled, so if you want to display more text, please consider using RadToolTip / RadToolTipManager.


Best wishes,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
johnathan
Top achievements
Rank 1
answered on 13 Jan 2009, 03:45 PM
My apologizes, I am using the radtooltip control.  Will I still be able to use the code from princey using the radtooltip?
0
Dimo
Telerik team
answered on 13 Jan 2009, 05:25 PM
Hello Johnathan,

Yes, Princy's code will still be of use.

If you are using RadToolTip, then you should implement something like this. Note that the RadToolTips resize automatically to accommodate their content, but you can also set Width and Height to RadToolTipManager.


<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Data" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
 
    protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            RadGrid grid = sender as RadGrid; 
            GridDataItem item = e.Item as GridDataItem; 
            foreach (GridColumn col in grid.MasterTableView.RenderColumns) 
            { 
                if (col is GridBoundColumn) 
                { 
                    (item[col.UniqueName] as TableCell).ToolTip = item[col.UniqueName].Text; 
                } 
            } 
        } 
    } 
     
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
    { 
        DataTable dt = new DataTable(); 
        DataRow dr; 
        int colsNum = 5
        int rowsNum = 100
        string colName = "Column"
 
        for (int j = 1; j <= colsNum; j++) 
        { 
            dt.Columns.Add(String.Format("{0}{1}", colName, j)); 
        } 
 
        for (int i = 1; i <= rowsNum; i++) 
        { 
            dr = dt.NewRow(); 
 
            for (int k = 1; k <= colsNum; k++) 
            { 
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1}Row{2}{0}{1}Row{2}{0}{1}Row{2}", colName, k, i); 
            } 
            dt.Rows.Add(dr); 
        } 
 
        (sender as RadGrid).DataSource = dt
    } 
 
</script> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
<style type="text/css"
 
/*Firefox fix*/ 
 
.GridRow_Default td, 
.GridAltRow_Default td 
    overflow:hidden; 
 
</style> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" AutoTooltipify="true" /> 
 
<p>Hover a RadGrid cell in order to view a RadToolTip:</p> 
 
<telerik:RadGrid 
    ID="RadGrid1" 
    runat="server" 
    Width="600px" 
    AllowPaging="true" 
    PageSize="20" 
    OnNeedDataSource="RadGrid_NeedDataSource" 
    OnItemDataBound="RadGrid_ItemDataBound"
    <MasterTableView TableLayout="Fixed" /> 
    <ClientSettings> 
        <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
    </ClientSettings> 
</telerik:RadGrid> 
 
</form> 
</body> 
</html> 
 



Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
johnathan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dimo
Telerik team
johnathan
Top achievements
Rank 1
Share this question
or