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

stop text from wrapping in rad grid

2 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
andieje
Top achievements
Rank 1
andieje asked on 09 Jul 2009, 12:20 AM
Hi

I'm using q3 2008 and the web blue skin for the rad grid. Please could you tell me how i would stop the text from wrapping in the grid rows. I would it to be trucated (with an elipsis if possible) if the text is too long. I'm a programmer and not a designer and I'm assuming this will be a trivial question for someone who knows what they are doing :)

thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Jul 2009, 07:44 AM
Hello,

You can try out the following code to wrap text in grid when its too long:
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
      if (e.Item is GridDataItem && !(e.Item.IsInEditMode)) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
            { 
                if (col is GridBoundColumn) 
                { 
                    string strtxt = dataItem[col.UniqueName].Text; 
                    if (dataItem[col.UniqueName].Text.Length > 10) 
                    { 
                        string temp = dataItem[col.UniqueName].Text; 
                        temp = temp.Remove(10); 
                        temp += "..."
                        dataItem[col.UniqueName].Text = temp; 
                        dataItem[col.UniqueName].ToolTip = strtxt; 
                    } 
                } 
            } 
        }   
     } 

Thanks
Princy.
0
andieje
Top achievements
Rank 1
answered on 09 Jul 2009, 06:34 PM
Many thanks. I didn't think about doing it programmatically but i need a tooltip displaying the whole text so i may as well do the lot programmatically!
Tags
Grid
Asked by
andieje
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
andieje
Top achievements
Rank 1
Share this question
or