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

[Solved] Multiline cell content??

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Malek
Top achievements
Rank 1
Malek asked on 21 Jul 2009, 06:04 PM
Hi,

My client has a weird request, but I have to find him a solution.

Data sent to a cell contains returns cariages ("\n") but it does not show properly in the cell, the whole text shows as a single long line.

What is the property to make the row expand its height to show the whole text with all the return cariages interpreted correctly?? 

I know its ugly, but thats what is needed at the moment.

P.S. I did parse the text before sending it to the grid and replacing all the \n by  Environment.NewLine but to no avail.

Thank you

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Jul 2009, 07:50 PM
Hello Malek,

I recommend you use line break tag  <br /> instead of \n or Environment.NewLine.

Example:

C#
TableCell cell = e.Item.Cells[0]; 
cell.Text = "Line 1<br />Line 2<br />Line 3"

GridTemplateColumn
<ItemTemplate> 
    Line 1<br />Line 2<br />Line 3 
</ItemTemplate> 

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Malek
Top achievements
Rank 1
answered on 21 Jul 2009, 09:28 PM
Hi,

I tried the <br /> but for some reason the RadGrid was not accepting it (it showed in the cell as text).

It had to be done in the PreRender event, thats what I did finally:

    protected void grdResult_PreRender(object sender, EventArgs e)
    {
         foreach(GridDataItem data in grdResult.Items){
             TableCell aCell = data["Requested_For"];
             aCell.Text = aCell.Text.TrimEnd(';');
             aCell.Text = aCell.Text.Replace(";", "<br />");
         }
    }

(the semicolumn represents the places where a <br /> was needed)
0
Daniel
Telerik team
answered on 22 Jul 2009, 06:38 AM
Hello Malek,

I'm unable to reproduce the depicted issue locally. Could you please test the attached sample project (based on your code) on your side?

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Malek
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Malek
Top achievements
Rank 1
Share this question
or