Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jon on Oct 06, 2008 21:12
open dhtmlx forum
Grid: Controlling focus

Hi all,

I have more than 1 grid on my page, as well as other buttons, tabs and regular HTML form fields.

I am having trouble controlling the focus of the grids when the user selects other fields and buttons on my page.

Examples:

1) In IE & FF, when i mouse-click on the page or on a form field OUTSIDE of the grid, the last grid cell being edited remains hilighted/selected.

2) In IE, when I use "accesskey" (alt+key) to place focus on an href element elsewhere on my page, the focus goes there, but as soon as I press TAB, focus jumps back to the last cell being edited in the grid.

3) Many more examples...

Basically, can you just tell me what functions I can call to KILL THE FOCUS AND/OR SELECTION on the grid?

I have tried playing with "grid.setActive(true|false)", and the "grid._still_active" property, but these seem to have no effect at all.

Please help!
Thanks,
Jon.
Answer posted by Support on Oct 07, 2008 03:09
>>when i mouse-click on the page or on a form field OUTSIDE of the grid, the last grid cell being edited remains hilighted/selected
The only situation when such behavior possible - you have some custom onclick handlers assigned to the page elements, which block event propagation. Grid liste "onclick" event on document.body, and if event blocked on some high level elements, grid will not known about click event and will not react on it. 

>>Basically, can you just tell me what functions I can call to KILL THE FOCUS AND/OR SELECTION on the grid?

grid.setActive(true); //move focus to the grid
grid.setActive(false); //mark grid as not focused

Beware that any mouse activity in grid ( clicking, dragging, etc.)  will make grid active. 
Also , some API calls, such as selectRow mark grid as active.

In case of IE, if you plan to control active state of grid manually, it has sense to add next line to the grid's init 

grid.entBox.onbeforeactivate=grid.entBox.onbeforedeactivate=null;
It will disable auto-focusing of grid in IE.


Answer posted on Nov 05, 2008 07:35
How to focus on particular cell?
Answer posted by Support on Nov 05, 2008 08:43
grid.selectCell(rowIndex,cellIndex)
grid.editCell();

It will switch cell to edit state and will move active focus inside cell's editor