This is a migrated thread and some comments may be shown as answers.
Binding a multiline textarea into the grid
2 Answers 93 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ben
Top achievements
Rank 1
Ben asked on 10 Apr 2012, 06:46 AM
So one of my columns is defined as such:

columns.Bound(o => o.DeliveryInstructions)
       .ClientTemplate("<textarea name='DeliveryInstructions' disabled='disabled' cols='40' rows='1'><#= DeliveryInstructions#></textarea>");

Which displays the data nicely. The problem is that using Ajax Editing, the nice big textarea reverts to a single line when editing. How can I fix this?

2 Answers, 1 is accepted

Sort by
0
Ben
Top achievements
Rank 1
answered on 11 Apr 2012, 12:45 AM
Anyone?
0
Accepted
Andrew
Top achievements
Rank 1
answered on 13 Apr 2012, 01:37 AM
Here is a solution:

In Views\Shares\EditorTemplates, create the TextArea.cshtml

@model string
@(Html.TextAreaFor(o => o, new { cols="40", rows="1" }))

Add UIHint to the Model object

public class Order
{
  [UIHint("TextArea")]
  public string DeliveryInstructions { getset; }
}

Note: You may use Server Template for the column as follow: 

columns.Bound(o => o.DeliveryInstructions).Template(
  @<text>
    <textarea disabled='disabled' cols='40' rows='1'>@item.DeliveryInstructions</textarea>
  </text>);

Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Ben
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or