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

Can't press "Enter" to fire Update Command when using MultiLine RadTextBox in RadGrid Edit Template.

5 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
LamKhoa
Top achievements
Rank 1
LamKhoa asked on 15 Aug 2012, 05:01 PM
Hi,

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

Sort by
0
Milena
Telerik team
answered on 20 Aug 2012, 10:24 AM
Hello,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
LamKhoa
Top achievements
Rank 1
answered on 21 Aug 2012, 01:59 AM
Hi,

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.
0
Milena
Telerik team
answered on 23 Aug 2012, 03:45 PM
Hello,

Please find the attached sample project.

Kind regards,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
LamKhoa
Top achievements
Rank 1
answered on 26 Aug 2012, 02:16 AM
Thanks,

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.
0
LamKhoa
Top achievements
Rank 1
answered on 26 Aug 2012, 03:06 PM
Thanks,

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.

Tags
Grid
Asked by
LamKhoa
Top achievements
Rank 1
Answers by
Milena
Telerik team
LamKhoa
Top achievements
Rank 1
Share this question
or