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

Enter = New Line in MultiLine Text Cell

8 Answers 856 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Crane101
Top achievements
Rank 1
Crane101 asked on 05 Sep 2011, 01:37 PM

Can't seem to find an answer that works on the forums anywhere for this one.

When I press enter when in edit mode on a text cell, I want to insert a new line rather than ending the cell edit, but no combination of catching key presses or any other grid or cell events seems to be able to achieve this.

Any help with this would be greatly appreciated.

Shane

8 Answers, 1 is accepted

Sort by
1
Accepted
Alexander
Telerik team
answered on 08 Sep 2011, 12:49 PM
Hello Shane,

Thank you for your question. The AcceptsReturn property of GridViewTextBoxColumn defines how the editor handles Enter key - end edit ('false', default value) or create new line.

If you have further questions, we will be glad to help.

Best regards,
Alexander
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Crane101
Top achievements
Rank 1
answered on 12 Sep 2011, 04:48 PM
Brilliant - thanks very much for that. Kinda obvious once you've got the answer!

Shane
0
Aravind
Top achievements
Rank 1
answered on 22 Oct 2015, 12:26 PM

Can you please tell how to edit this??

 

I tried including the following code, so that a new row is created when you press enter WHILE YOU'RE EDITING one particular cell.


$(document).on('keypress','#grid',function(event){
    var keycode = (event.keyCode ? event.keyCode : event.which);
  if(keycode == '13'){
    grid.addRow();

  } 
});

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Oct 2015, 12:46 PM
Hello Aravind,

Thank you for writing.

Note that this forum is related to the UI for WinForms product. However, your question seems to be related to Kendo UI. I would kindly ask you to post your question in the appropriate forum: http://www.telerik.com/forums/kendo-ui.

Thank you for your understanding.

Regards,
Dess
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
0
OD
Top achievements
Rank 1
answered on 09 Dec 2015, 01:16 PM
Don't forget to set MultiLine to true before ;)
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Dec 2015, 08:33 AM
Hello ,

Thank you for writing.

Indeed, it is necessary to enable the multiline text for the editor as well:
public Form1()
{
    InitializeComponent();
 
    foreach (GridViewColumn col in this.radGridView1.Columns)
    {
        GridViewTextBoxColumn tbCol = col as GridViewTextBoxColumn;
        if (tbCol != null)
        {
            tbCol.AcceptsReturn = true;
        }
    }
}
 
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
    RadTextBoxEditor tbEditor = e.ActiveEditor as RadTextBoxEditor;
    if (tbEditor != null)
    {
        RadTextBoxEditorElement element = tbEditor.EditorElement as RadTextBoxEditorElement;
        element.TextBoxItem.Multiline = true;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
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
0
liebgotts
Top achievements
Rank 1
answered on 24 Jul 2017, 04:27 PM

Hi,

 

I'm still having trouble with this despite setting the Multiline and AcceptsReturn properties of my text columns to true. When pressing Enter in a new row, EndEdit is called and the new row is added. Only when I edit an existing row can I insert carriage returns.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jul 2017, 09:40 AM
Hello , 

Thank you for writing.  

Pressing Enter key on the new row will commit the row data by default. However, when multiline is enabled and the GridViewTextBoxColumn.AcceptsReturn property is set to true, you can enter multiline text in the new row. Please refer to the attached sample project which result is illustrated in the attached gif file with the latest version.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Crane101
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Crane101
Top achievements
Rank 1
Aravind
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
OD
Top achievements
Rank 1
liebgotts
Top achievements
Rank 1
Share this question
or