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

Desperate for help - setting row height and overflow

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Todd Davis
Top achievements
Rank 1
Todd Davis asked on 27 Sep 2009, 02:18 AM
I have a radgrid on my web page with several columns of data. One of those columns contains a fairly large amount of text data in every row, so the row heights are pretty huge. I tried setting  ItemStyle-Height="20px". but that did absolutely nothing to resolve the problem. Clearly the height is adjusting to accommodate all the text in the cell, but that's not what I want in this case. I want the text overflow to be hidden.

One special note - This grid (and the text in particular) is going to be exported to XLS, so I don't want to shorten it (i.e. add some function to show only (x) characters). It needs to be available, just offscreen.

I'm on a tight timeline, so please help me!

Thanks,

-Todd

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Sep 2009, 12:11 PM
Hello Todd,

Table cells in general do not support the behavior that you are after. You need to use a template column or insert a <div> tag around the text content. Here is an example showing the latter:

<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Data" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<script runat="server"
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
    { 
        string s = "This is a long string, which will be used inside a special RadGrid cell."
        string MyLongString = String.Format("{0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0}", s); 
         
        DataTable dt = new DataTable(); 
        DataRow dr; 
        dt.Columns.Add("Column1"); 
 
        for (int i = 1; i <= 5; i++) 
        { 
            dr = dt.NewRow(); 
            dr["Column1"] = MyLongString; 
            dt.Rows.Add(dr); 
        } 
 
        (sender as RadGrid).DataSource = dt
    } 
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.ExportToExcel(); 
    } 
     
</script> 
 
<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" media="screen"
 
.mydiv{height:24px;overflow:hidden} 
 
</style> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadGrid 
    ID="RadGrid1" 
    runat="server" 
    Width="600px" 
    Skin="Office2007" 
    AutoGenerateColumns="false" 
    OnNeedDataSource="RadGrid_NeedDataSource"
    <MasterTableView> 
        <Columns> 
            <telerik:GridBoundColumn DataField="Column1" HeaderText="Large Text Column" DataFormatString="<div class='mydiv'>{0}</div>" /> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
 
<asp:Button ID="Button1" runat="server" Text="Export to XLS" OnClick="Button1_Click" /> 
 
</form> 
</body> 
</html> 


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Todd Davis
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or