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

Set Focus to cell when grid is in BatchEdit=row

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 06 Mar 2015, 07:45 PM
Okay, 

I have a grid with BatchEdit = row, AllowKeyboardNavigatoin=true and I have written some javascript to allow ctrl arrowup and ctrl arrowdown to move to the previous row or next row.  When moving to the previous or next row, the row is opened for Row Edit.

The row is opened but focus is set to the first editable column. How can I set focus to the cell (column) where the cursor was previously located?  

I would like to be able to scroll update and down the rows and stay in the same column.

<js>
function arrowKeypress(e) {

            var grid = $find("<%=RadGrid1.ClientID%>");
            var row = grid.get_batchEditingManager().get_currentlyEditedRow();

            selectedColumn = e.currentTarget.cellIndex;
                        
            if (e.keyCode == 38 && e.ctrlKey) {
                // Arrow Up
                var row = grid.get_batchEditingManager().get_currentlyEditedRow();
                if (row.previousSibling) {
                    grid.get_batchEditingManager().openRowForEdit(row.previousSibling, selectedColumn);
                }
            
            }
            else if (e.keyCode == 40 && e.ctrlKey) {
                //Arrow Down
                if (row.nextSibling) {
                    grid.get_batchEditingManager().openRowForEdit(row.nextSibling);
                }
            }
            return true;
             
        }
</js>

Thank you.

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 11 Mar 2015, 10:53 AM
Hi Fred,

I have prepared a sample project where the arrow keys are used to switch between the edited cell. The sample is using BatchEditingSettings-EditType="Cell". This way the user will be able to navigate left and right in addition to up and down.

Give the attached sample a try and see how it works for you.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Fred
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or