How do I wrap contents of long non space text in a RadGrid column?
Please review the attachment.
I tried following code ,it not helping.
Thank you.
Please review the attachment.
I tried following code ,it not helping.
Thank you.
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
SortExpression
=
"ShipName"
UniqueName
=
"ShipName"
>
<
ItemStyle
Wrap
=
"false"
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 10 Dec 2010, 11:32 AM
Hello Thees,
Give a try with the following approach to achieve this.
ASPX:
Also go through the following documentation which explains how to prevent the wrapping for column cells content.
No wrap for grid cell content
Thanks,
Princy.
Give a try with the following approach to achieve this.
ASPX:
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
SortExpression
=
"ShipName"
UniqueName
=
"ShipName"
>
<
HeaderStyle
Wrap
=
"false"
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
Also go through the following documentation which explains how to prevent the wrapping for column cells content.
No wrap for grid cell content
Thanks,
Princy.
thees
commented on 13 Dec 2010, 03:21 AM
Top achievements
Rank 1
Hi,
Sorry i included wrong code.Basically i need to wrap the cell.
I tried both codes
When the string have space it working correctly,it is not working when string don't have space.
Thank you.
Sorry i included wrong code.Basically i need to wrap the cell.
I tried both codes
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
ItemStyle-Wrap
=
"true"
SortExpression
=
"ShipName"
UniqueName
=
"ShipName"
>
<
ItemStyle
Wrap
=
"true"
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
SortExpression
=
"ShipName"
UniqueName
=
"ShipName"
>
<
HeaderStyle
Wrap
=
"true"
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
When the string have space it working correctly,it is not working when string don't have space.
Thank you.
Shinu
commented on 13 Dec 2010, 01:48 PM
Top achievements
Rank 2
Hi,
For the wrap to take place properly, the cell text must contain white space in between. But in your case, unfortunately, there is no space in the item text. In this situation one possible option would be to setting the tooltip for cell , which would show the complete text of the cell, when the user hovers over it and cut the cell text to particular length (and show ellipsis for cell text).
You can perform this in ItemDataBound event of grid.
Accessing cells and rows
-Shinu.
For the wrap to take place properly, the cell text must contain white space in between. But in your case, unfortunately, there is no space in the item text. In this situation one possible option would be to setting the tooltip for cell , which would show the complete text of the cell, when the user hovers over it and cut the cell text to particular length (and show ellipsis for cell text).
You can perform this in ItemDataBound event of grid.
Accessing cells and rows
-Shinu.
0

Chris Poirier
Top achievements
Rank 1
answered on 22 Sep 2011, 07:38 PM
I was facing the same problem, and I have found a solution that works in all major browsers (IE7 specific CSS is required).
1) The width of the grid must be set in pixels. (Only necessary for IE7.)
2) Assign an ItemStyle.CSSClass to the column. (For this example, I have used "itemNameColumn")
3) Add the following to your CSS file:
4) For IE7, add the following CSS: (I used a conditional comment to create an IE7 specific CSS file)
Now it will break in the middle of a long word and will not break the styling of the table.
1) The width of the grid must be set in pixels. (Only necessary for IE7.)
2) Assign an ItemStyle.CSSClass to the column. (For this example, I have used "itemNameColumn")
3) Add the following to your CSS file:
.itemNameColumn span
{
display
:
block
;
width
:
225px
; /* Set this to the width you want to break at. */
word-wrap: break-word; /* This will not be recognized by Visual Studio, but it works. */
}
.itemNameColumn
{
position
:
relative
;
}
.itemNameColumn span
{
position
:
absolute
;
left
:
0
;
}
Now it will break in the middle of a long word and will not break the styling of the table.
0

Max T
Top achievements
Rank 1
answered on 31 Oct 2014, 07:31 PM
You could also try to use ItemDataBound code to wrap the text manually. That's what i ended up having to do.
If
e.Item.ItemType = GridItemType.AlternatingItem
Or
e.Item.ItemType = GridItemType.Item
Then
'Get a reference to the current item
Dim
gdiItem
As
GridDataItem = e.Item
If
gdiItem(
"settings_value_short"
).Text.Length > 50
Then
Dim
strValue
As
String
= gdiItem(
"settings_value_short"
).Text
Dim
intStringLength
As
Integer
= gdiItem(
"settings_value_short"
).Text.Length
Dim
intSection
As
Integer
= (intStringLength - (intStringLength
Mod
50)) / 50
While
intSection > 0
strValue = strValue.Substring(0, intSection * 50) &
"<br />"
& _
strValue.Substring(intSection * 50)
intSection -= 1
End
While
gdiItem(
"settings_value_short"
).Text = strValue
End
If
End
If
0

Disposable Hero
Top achievements
Rank 1
Iron
answered on 08 Aug 2019, 07:32 PM
I just referenced this style in ItemStyle-CssClass="wrapWord" attribute.
.wrapWord { word-wrap: break-word;word-break:break-all;}