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

[Solved] Should not wrap the text in radgrid coulmn.

2 Answers 346 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hrushikesh Mokashi
Top achievements
Rank 1
Hrushikesh Mokashi asked on 03 Mar 2009, 06:17 AM
Hi All,

I am using RadControls for ASPNET AJAX Q2 2008.

I am using Radgrid.
I have given the fix width to each column in grid.
When data is greater than the column width the it wrap the text to next line.
I want to show the grid row data in one line.
ie. It should show only that data which is fit in one row of secified column width.
It should not wrap the text automatically.

Thanks.




2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Mar 2009, 12:31 PM
Hi Hrushikesh,

Here is a help article which explains how to prevent wrapping of the Grid cell content. Go through it and see if it helps.
No wrap for grid cell content

Shinu



0
Jason Divis
Top achievements
Rank 1
answered on 04 Mar 2010, 07:07 PM
I followed this article, but receive the index out of range exception... is the doco outdated? I am also using grouping, could that be mucking it up?

http://www.telerik.com/help/aspnet-ajax/grdnowrapforgridcellcontent.html

Using v2009.3.1103.35

Thanks for your help.


.:edit:.

I was able to avert the index out of range exception by programmatically wrapping the text of each cell within the GridDataItem with "<nobr>"

ElseIf TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = CType(e.Item, GridDataItem)
            For Each cell As TableCell In item.Cells
                cell.Text = "<nobr>" + cell.Text + "</nobr>"
            Next

but as this seems that it would hamper performance, I went looking for a better solution, and found that the CSS:

td {white-space: nowrap;}

does the trick as well. If you didn't want all of your table cells to have no wrap, you could apply the nowrap to specific tables if you wanted as well by using an id selector or class selector.

Note: When I tried viewing a site in IE8's compatibility view, it did not support the nowrap CSS, even though W3schools states that all IE browsers support it (http://www.w3schools.com/css/pr_text_white-space.asp). It may be that IE7 supports it as well, just not IE8's compatibility view.

Hope this helps someone else.
Tags
General Discussions
Asked by
Hrushikesh Mokashi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jason Divis
Top achievements
Rank 1
Share this question
or