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

Disable "Enter Key" in Chrome

2 Answers 335 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rk.MooRthy(DLL Version : 2008.3.1314.35) asked on 23 Jan 2014, 01:37 PM
Hi,
I have one grid with dynamic text boxes are coming from DB. The issue is that If user go to Edit mode in the Grid and then user puts some values in text boxes at the time user clicks the Enter button in Chrome browser, the application will take the another button control and make the changes as per the button event, So i need to disable the Enter Key in chrome browser, But its working fine in firefox browser.
The issues in in chrome browser only, I have attached my grid and script code snippet below.

Can anyone help me regarding this issue..

This is my script..
function OnEnterKeyPress(sender, args) {
                var keypressed = args._keyCode;
                if (keypressed == "13") {
                     document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "Please use the Update Button";
                     args.set_cancel(true);
}

This is my Grid..
// This is my grid //
<telerik:RadGrid ID="RGRateCorrection" runat="server" AutoGenerateColumns="false"
                    Skin="Vista" OnNeedDataSource="RGRateCorrection_NeedDataSource" OnUpdateCommand="RGRateCorrection_UpdateCommand"
                    Width="1000px" Height="300px" HeaderStyle-Width="500px" ItemStyle-Width="500px"
                    OnItemDataBound="RGRateCorrection_ItemDataBound">
                    <MasterTableView EditMode="InPlace" EnableColumnsViewState="false" Width="1000px">
                        <Columns>
                            <telerik:GridEditCommandColumn ButtonType="LinkButton" UniqueName="EditCommandColumn">
                            </telerik:GridEditCommandColumn>
                        </Columns>
                    </MasterTableView>
                    <ClientSettings ClientEvents-OnKeyPress="OnEnterKeyPress">
                        <%-- AllowKeyboardNavigation="true"--%>
                        <Scrolling AllowScroll="true" />
                    </ClientSettings>
                </telerik:RadGrid>


-Thanks
Rk.MooRthy

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jan 2014, 04:53 AM
Hi ,

Please try the following code snippet to disable the Enter key:

JS:
function OnEnterKeyPress(sender, args) 
  
    if (args.get_keyCode() == 13) 
       
         var e = args.get_domEvent().rawEvent; 
          e.returnValue = false
          e.cancelBubble = true;                   
          if (e.stopPropagation) 
           
             e.preventDefault(); 
             e.stopPropagation(); 
           }              
       }             
   }

Thanks,
Princy
0
answered on 24 Jan 2014, 05:16 AM
Hi Princy,
Its working fine, thanks for your valuable reply.


-Thanks
Rk.MooRthy
Tags
Grid
Asked by
Answers by
Princy
Top achievements
Rank 2
Share this question
or