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

[Solved] Cell text on a single line

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
krishnen
Top achievements
Rank 1
krishnen asked on 25 Aug 2009, 01:36 PM
Hello,

Is there any way to display the text in a Radgrid column on a single line, with the whole text appearing as a tooltip , if the column width is not enough to display the whole text?

Thank you,
Krishnen

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2009, 01:50 PM
Hello Krishnen,

You can try out the folowing code to achieve your scenario:
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem dataitem = (GridDataItem)e.Item;  
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)  
            {  
                if (dataitem[col.UniqueName].Text.Length > 10)  
                {  
                    dataitem[col.UniqueName].ToolTip = dataitem[col.UniqueName].Text;  
                    dataitem[col.UniqueName].Text = dataitem[col.UniqueName].Text.Substring(0, 10) + "...";                      
                }                     
             }  
        }  
   }  


Hope this helps..
Shinu:)
0
krishnen
Top achievements
Rank 1
answered on 25 Aug 2009, 02:54 PM
Hi Shinu,

Works like a charm.
Thanks :-)

Krishnen

Tags
Grid
Asked by
krishnen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
krishnen
Top achievements
Rank 1
Share this question
or