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

Bind multiline TextArea to inCell Grid

4 Answers 1451 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mathias
Top achievements
Rank 1
Mathias asked on 04 Sep 2012, 10:37 AM
Hello,

I am using an inCell editable grid and I want to use a textarea in one column.

The column looks like this:
columns.Bound(p => p.Reason).Title("Reason")
.ClientTemplate("<textarea rows='2' style='text-overflow:ellipsis; display:block; width:99%; height:100%; font-family:Arial; font-size:12px;' readonly='readonly'>#= Reason #</textarea>");


And the Editor-Template like this:
@model string
 
@Html.TextAreaFor(m => m, new { rows = 2, cols = 35, wrap = "hard",  @readonly = true, style = "text-overflow:ellipsis; display:block; width:99%; height:100%; font-family:Arial; font-size:12px;" })


My problem is, that I have to click outside the textarea of my ClientTemplate (but still inside the cell) to get the cell switched into the edit-mode. Is there any possibility to get the edit-mode by clicking anywhere in the cell... also if I click on the readonly-textarea which is defined in the ClientTemplate?

If i don't use a ClientTemplate, the text which gets inserted, especially the returns won't be shown and the whole text is in one line.

Does anyone have a solution for that?

4 Answers, 1 is accepted

Sort by
0
Accepted
Flappie
Top achievements
Rank 1
answered on 12 Sep 2012, 12:29 PM
Hello,

This may be somewhat late, but maybe still helpful, if only for those who randomly find this thread...

Have you tried using the <pre> tag in the Client Template rather than a textarea? You'll have to style it to use a different font, but you're doing that for the textarea anyway.
0
Mathias
Top achievements
Rank 1
answered on 17 Sep 2012, 07:59 AM
Hi Flappie,

thank you for your hint. With the pre-tag everything works perfectly! I used the following styles (if someone needs the same stuff):
height: 60px;
overflow: auto;
margin-top: 0px;
margin-bottom: 0px;


0
TroyR
Top achievements
Rank 1
answered on 27 Apr 2016, 03:08 PM

Thank you all for this thread!  I need a bit more explanation on the original post's code set up to accomplish something similar.

How does his grid know to run the Editor-Template partial-view when he clicks into that column's cells?

If you can, please reply with an example or link in C# MVC.  Thanks!

0
Konstantin Dikov
Telerik team
answered on 02 May 2016, 10:37 AM
Hi Troy,

You could refer to the following help article and online demo for detailed information regarding the Editor templates:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mathias
Top achievements
Rank 1
Answers by
Flappie
Top achievements
Rank 1
Mathias
Top achievements
Rank 1
TroyR
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or