dhtmlxgrid - set focus to grid by default upon page load?

Is there a programmatic way to set focus on a grid upon initial page load?



The only way I’ve been able to get this to somewhat work is if I call selectRow() to force the 1st row to be selected - which is not desired. I’d like to simply have fous on the grid so that the user can then use the up/down arrow keys to navigate the grid (if desired), without having to click on a row first. Possible?

After calling selectRow() method focust sets on the grid and you are able to navigate the grid. Please check if you are calling this method after grid was loaded:
mygrid.loadXML(“100.xml”,function(){
mygrid.selectRow(2)
});
Also you can mark necessary row as selected via “selected” xml attribute:


Thanks, but I was trying to avoid having to select a row by default.



I was able to create the desired behavior by creating a hidden row at index 0 and making that row selected by default. That sets focus on the grid and allows for arrow key navigation, without giving the appearance of having a row selected or causing an unnecessary server hit (it’s a high volume header/detail type of use and we don’t want to load the detail pane unless necessary).  I just had to add logic to my onRowSelect event to catch selections of this row (e.g. via page up) and force that selection to be made on the 1st visible row @ index 1.