0

Using Dojo 1.5, how do I programmatically put a DataGrid cell in edit mode? Say I want a button's onclick event to trigger the inline editor for a cell with the field name of 'alias' and rowId of 4. I tried grid.doStartEdit("alias", 4), but it doesn't appear to do anything (or cause any errors) and I can't find any documentation on this.

1 Answer 1

1

The following works for me:

function startEdit(grid, rowIndex, cellIndex) {
    var cell = grid.getCell(cellIndex);
    grid.setFocusCell(cell, rowIndex);
    grid.setEditCell(cell, rowIndex);
}

This won't work directly if the row you're trying to edit was just created, say for instance, the user clicked the Insert key, you inserted a new row and now want to put the first cell in that row in edit mode so the user can fill in their data. If that's what you're doing, you're going to have to call this function with setTimeout, to allow the store enough time to get its data into the grid.

Not the answer you're looking for? Browse other questions tagged or ask your own question.