I have set the RadGrid Edit Mode to be "InPlace". I have also enabled the keyboard support on the RadGrid so that while in Edit mode, if I press enter after finished typing a line, the Update Command will fire. It works great in Single-Line RadTextBox, but not with Multi-Line RadTextBox, as in Multi-Line mode, when I press Enter, the caret move to the next line in the textbox instead of firing Update Command.
I tried Ctrl + Enter, Shift + Enter, Alt + Enter, but none of them can trigger the Update Command.
Please let me know if there any work-around on this issue.
Thanks
Lamk.
5 Answers, 1 is accepted
RadTextBox does not have a special property, which controls the behavior of multiline textbox when the enter key is pressed. However, you can change the default behavior as use the following code:
<
script
type
=
"text/javascript"
>
function MyKeyPress(sender,args)
{
if (args.get_keyCode() == 13)
{
sender.set_value(sender.get_textBoxValue());
__doPostBack(sender.get_id(),"");
}
}
</
script
>
<
telerik:RadTextBox
TextMode
=
"MultiLine"
ID
=
"RadTextBox1"
runat
=
"server"
>
<
ClientEvents
OnKeyPress
=
"MyKeyPress"
/>
</
telerik:RadTextBox
>
All the best,
Milena
the Telerik team
I have tried as you suggested, but it didn't work, when I press Enter, the text is reverted back to its original value, and the grid still in edit mode.
If it works in yours, would you please attach for me a sample project?
Thanks
Lamk.
Please find the attached sample project.
Kind regards,
Milena
the Telerik team
I have tried to run your project.
The "Default Button", when be clicked manually, it's really update the grid. However, if we trigger-clicked it through pressing enter in the MultiLine Textbox, it's appeared that the "Default" button is clicked, but the grid is still in Edit Mode, and isn't updated.
Would you please check your project again?
Thanks.
Lamk.
I have eventually made it work by modifying your MyKeyPress javascript method as follow:
function MyKeyPress(sender, args)
{
if (args.get_keyCode() == 13) //Detect if Enter Key Is Press While In TextBox
{
sender.set_value(sender.get_textBoxValue());
var grid = $find('RadGrid1_PatientRecord'); //The ID Of the RadGrid
var idx = grid._editIndexes[0]; //Assume that only one record can be edit at a time
if (idx != null)
{
$find(grid.MasterTableView.get_id()).updateItem(parseInt(idx));
}
else
{
alert("Not Update"); //Let User Know if the update didn't work.
}
}
}
(I was trying to implement CTRL + Enter to enter new line like in FB Chat, However, I have just checked with my client, they said that they really don't need to enter new line in the textbox.)
Please go ahead and make this thread as "Answered"
Thanks
Lamk.