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
180
Data Entry Grid
posted

Looking for a sample app using webdatagrid. All it has is a sql datasource using one cell. I need the first cell to be in editmode on page load and on the enter key down put the next cell in edit mode. thanks

Parents
  • 29417
    Suggested Answer
    Offline posted

    Hello mburk2 ,

     

    You can manually force a cell in edit mode using the enterEditMode method of the cell editing behavior. For example:

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

       editing.enterEditMode(cell);

     

    To enter edit mode on the initial load you can handle the Initialize event and in it enter edit mode for the first cell. For example:

      function wdg_init(sender,e) {

            var firstCell = sender.get_rows().get_row(0).get_cell(0);

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

            editing.enterEditMode(firstCell);

            editedCell = firstCell;

        }

     

    By default on “Enter” key the cell exits edit mode. In order to force it to enter edit mode for the next cell you can handle the key down event and change the current edited cell programmatically. For example:

       function wdg_keyDown(sender,e) {

            if (e.get_browserEvent().keyCode == 13) {

           //check if Enter key has been hit

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

                var currentCellInEditMode = editedCell;

                var cellIndex=currentCellInEditMode.get_index();

                 var nextCell;

                if(cellIndex+1<sender.get_columns().get_length()) {

                //check whether this is the last cell for the column

                nextCell = currentCellInEditMode.get_row().get_cell(cellIndex+1);           

                }

                else {

                //if it's the last cell move to the next row

                var nextRow=sender.get_rows().get_row(currentCellInEditMode.get_row().get_index()+1);

     

                nextCell=nextRow.get_cell(0);

                }

            editing.enterEditMode(nextCell);

            editedCell = nextCell;

            }

        }

     

     

    Please refer to the attached sample and let me know if you have any questions.

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://es.infragistics.com/support

     

    WDG_EnterKey.zip
Reply Children