Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Malcolm Abulu on Oct 04, 2008 17:13
open dhtmlx forum
DhtmlGrid

How can i set focus to a cell and have it automatically open up the editor.

I tried

grid.selectCell();
grid.editCell();

but the editor doesnt open.

The idea is to have the user click a toolbar button.
This button creates a new row in the grid, goes to the first editable cell and opens the editor.
Answer posted by Support on Oct 06, 2008 03:20
The code which you are using is correct, the problem may be caused by event bubbling. 
If you run such action from some kind of button from outside the grid, it will generate onClick event , which will reach document.body, and grid has logic which cause closing of currently active editor , when click outside of grid occurs. 

- you code run
- editor opened
- onclick reach document.body
- grid reacts on click outside of grid
- editor closed

To fix issue - just stop the event bubbling

<input type="button" onclick="doIt(arguments[0])"

function doIt(e){
   grid.selectCell(); 
   grid.editCell();
   (e||event).cancelBubble=true;
}