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

Wraping Of Text in table cell

4 Answers 444 Views
Grid
This is a migrated thread and some comments may be shown as answers.
C
Top achievements
Rank 1
C asked on 23 Apr 2008, 04:19 PM


If I had long text in table cell. eg:
    "the quick brown fox jumped over the gate"

I would click to clip the Text in the cell like this:
    "the quick brown ...."

I DON'T want it to wrap on many lines eg
    "The quick brown 
    fox jumped over 
    the gate"

I have tried nowrap. did not work


4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Apr 2008, 06:14 AM
Hi C,

Go through the following help document link.
Resizing columns

Thanks
Princy.
0
Dimo
Telerik team
answered on 24 Apr 2008, 08:13 AM
Hello Chris,

The browser support for what you request is rather inconsistent, however, this behavior is achievable. Please find attached an ASPX file with sample XML datasource demonstrating the required steps:

1) You have to use template columns in order to insert a <div> element around your data in each grid cell.

2) You have to set <MasterTableView TableLayout="Fixed"> or set width explicitly to each column by using HeaderStyle-Width="..."

3) Some additional CSS styles need to be applied to the data cells and the template wrapping <div>s, namely - white-space:nowrap, overflow:hidden and text-overflow:ellipsis. Please note that text-overflow:ellipsis (the property which adds the three dots) is only supported by Internet Explorer. Firefox will only clip the cell content and users may not guess that some text is not visible.

Let us know if you need more information.

All the best,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
denpro
Top achievements
Rank 2
answered on 17 Jan 2009, 02:05 AM

Here is another way I found to clip the cell size through code behind.  
 

Default.aspx

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false">  
<HeaderContextMenu EnableTheming="True" >   
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>   
</HeaderContextMenu> 
<MasterTableView datasourceid="SqlDataSource1" DataKeyNames="ID">  
<Columns> 
<telerik:GridBoundColumn DataField="ID" HeaderText="id"  UniqueName="Id">  
</telerik:GridBoundColumn> 
<telerik:GridBoundColumn DataField="Description" HeaderText="Description" Resizable="true" UniqueName="Description">  
</telerik:GridBoundColumn> 
</Columns> 
</MasterTableView> 
<FilterMenu EnableTheming="True">  
<CollapseAnimation Type="OutQuint" Duration="200">  
</CollapseAnimation> 
</FilterMenu> 
</telerik:RadGrid> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:strConnectionString %>" ProviderName="<%$ ConnectionStrings:strConnectionString.ProviderName %>" SelectCommand="SELECT id, description FROM Sampletable">  
</asp:SqlDataSource> 
 

 

Default.aspx.vb

Imports Telerik.Web.ui  
Partial Class default.aspx  
    Inherits System.Web.UI.Page  
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
        If TypeOf e.Item Is GridDataItem Then 
            Dim gridDataItem As GridDataItem = DirectCast(e.Item, GridDataItem)  
            gridDataItem.ToolTip = gridDataItem("Description").Text.ToString  
            Dim colWidth As Integer = 25  
            If Len(gridDataItem("Description").Text.ToString) > (colWidth - 2) Then 
                gridDataItem("Description").Text = Mid(gridDataItem("Description").Text, 1, colWidth - 2) & ".." 
            End If 
        End If 
    End Sub 
End Class 

 

0
Dimo
Telerik team
answered on 19 Jan 2009, 06:12 AM
Hello denpro,

That's right, you can use ItemDataBound and remove the excessive content as well.

Kind regards,
Dimo
the Telerik team

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