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

Pressing 'Enter' is cancelling edit mode

2 Answers 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NVB
Top achievements
Rank 1
NVB asked on 28 Nov 2012, 07:15 PM
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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2012, 05:11 AM
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
0
NVB
Top achievements
Rank 1
answered on 30 Nov 2012, 12:54 AM
That worked. Thanks very much .
 Need to undesrstand each statement in javascript

Thanks
 
Tags
General Discussions
Asked by
NVB
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
NVB
Top achievements
Rank 1
Share this question
or