Pressing 'Enter' is cancelling edit mode

3 posts, 0 answers
  1. NVB
    NVB avatar
    39 posts
    Member since:
    Apr 2009

    Posted 28 Nov 2012 Link to this post

    I am doing inline edit  in radgrid

    My Radgrid displays 10 rows.

    When I edit the first row ,change the data and press 'enter' key. it saves the data perfectly

    If I edit any row other than 1st  row. after changing the data  and press 'enter'  (not the save button) it closes the edit mode and data is not saved. It behaves as if 'enter' is cancelling the edit mode. And more over  it automatically opens the 1st row for edit

    How can we make sure if 'enter' is pressed in edit mode save/update is triggered.

    Please note that it works fine I click the save button, the problem I press 'enter' key  and happens only for other than 1st row

    Following is my editcommand colum

    <telerik:GridEditCommandColumn HeaderStyle-Width="60px" UniqueName="EditCommandColumn"

     

    Visible="true" ButtonType="ImageButton" HeaderText="Edit">

    </telerik:GridEditCommandColumn>

    Hope I am clear  with my question.

    Aprreciate your help.

    Thanks

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Nov 2012 Link to this post

    Hi,

    Please try the following code snippet.

    ASPX:
    <ClientEvents OnKeyPress="KeyPressed" />

    Javascript:
    <script type="text/javascript">
        function KeyPressed(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();
                }
            }            
        }
    </script>

    Thanks,
    Princy
  3. NVB
    NVB avatar
    39 posts
    Member since:
    Apr 2009

    Posted 29 Nov 2012 Link to this post

    That worked. Thanks very much .
     Need to undesrstand each statement in javascript

    Thanks
     
Back to Top