Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
875
Key Enter action on Row Adding
posted

Hello

 

I want to know if can disable “key enter” action on row adding, because I trigger a postback in an event fired after a cell has exited edit mode.

 

GridViewData.RowUpdating += new RowUpdatingHandler(GridViewData_RowUpdating);

GridViewData.Behaviors.EditingCore.Behaviors.CellEditing.CellEditingClientEvents.ExitedEditMode = "GridViewData_CellEditing_ExitedEditMode";

 

And in the page aspx I have the follow:

 

<script type="text/javascript" id="igClientScript">

        function GridViewData_RowAdding_ExitedEditMode(webDataGrid, evntArgs) {           

            var grid = webDataGrid;            grid.get_behaviors().get_editingCore().get_behaviors().get_rowAdding()._commitRow();

        }

    </script>

 

This is okay, because I need it.

 

In this case, when I’ve exited of a cell edit mode (pressing any key or changing focus), I get a postback and a commit row, but also, when I press “enter key”, get two postbacks and two commits row, and it’s wrong.

 

Does any way to prevent “key enter” action in GridViewData_RowUpdating(…) function?

How can I solve this problem? Please, help me!

 

Thanks.

Geovanny Domínguez.

Parents
No Data
Reply
  • 37874
    posted

    Hello Geovanny,

    I would suggest you to cancel RowAdding ExitingEditMode client-side event if the key pressed is 'enter'. You can use code, similar to the following:

    function WebDataGrid1_RowAdding_ExitingEditMode(sender, eventArgs)
    {
        if (eventArgs.get_browserEvent().keyCode == 13) {
            eventArgs.set_cancel(true);
        }
    }

    Let me know if this helps.

Children