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
425
Using downArrow or upArrow
posted

I am using a WebGrid with EnableF2="False" and EnableOnKeyPress="True".

I have users that need to type values on rows of some colum in a WebGrid.

Is there a way for the user to type a value in a cell and then just pressing downArrow key, move the focus to the cell below, saving the data?

With the settings I am using now, after typying the value, I have to press ENTER and only after that I can press downArrow to move the focus.

I do not want to press ENTER, I just want to press downArrow key.

You can see this behavior at this link:

http://wijmo.com/demo/explore/?widget=Grid&sample=Editing

Try to change the value of DISCOUNT column and then press downArrow, note that the value is saved and the focus moved to the cell below,

Another nice issue is: try to click in the QUANTITY HEADER, note that the focus moves to the first cell

Is there a way to have these behaviors using WEBGRID?

Thanks!

Edson

Parents
  • 29417
    Offline posted

    Hello Edson,

     

    Thank you for posting in our forum.

     

    Are you using the UltraWebGrid controls or the WebDataGrid one?

    Generally the two properties you’ve set seems to be from the WebDataGrid’s CellEditing behavior under the EditModeActions so I presume that the control you’re using.

    Generally the grid would keep the focus inside the cell by default until you hit enter or click on another cell. You could add some custom logic to handle the cases when the key up or down have been hit and manually change the cell that’s in edit mode. For example:

     

    function WebDataGrid1_Grid_KeyUp(sender, eventArgs)

    {     

        if (eventArgs.get_browserEvent().keyCode == "40") {

            //down

            var cellEditing = sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing();

            var currentCell=cellEditing.get_cellInEditMode();

            var rowInd=currentCell.get_row().get_index()+1;

            cellEditing.exitEditMode(true);

            if (rowInd < sender.get_rows().get_length()) {

                var nextCell = sender.get_rows().get_row(rowInd).get_cell(currentCell.get_index());

                cellEditing.enterEditMode(nextCell);

            }

        }

        if (eventArgs.get_browserEvent().keyCode == "38") {

            //up

            var cellEditing = sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing();

            var currentCell = cellEditing.get_cellInEditMode();

            var rowInd = currentCell.get_row().get_index() - 1;

            if (rowInd > 0) {

                cellEditing.exitEditMode(true);

     

                var nextCell = sender.get_rows().get_row(rowInd).get_cell(currentCell.get_index());

                cellEditing.enterEditMode(nextCell);

            }

        }

     

    }

    Let me know if that would work for your scenario.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Reply Children