How to enter the grid by using the tab key ?
It is possible to set the tabindex on the html div declaring the tab but it will only focus the whole div. I would like to focus on the first cell of the first row.
Personaly I came up with the following hack but I am looking for a better solution. Any external lib is welcome.
I have only one column in my grid and simple rows, so this code should be improved to remove potential focus on all cells for all columns and/or for rows with more than one level.
Inside my directive
<div ag-grid="ctlr.gridOptions" class="ag-fresh" role="grid" tabindex="201" ng-focus="ctlr.onFocus()" id="myGrid"></div>
Inside controller
ctrl.onFocus = function()
{
var rows = $('#myGrid .ag-row.ag-row-even.ag-row-level-0');
var firstRow = rows[0];
var firstColumnCells = $('#myGrid .ag-row.ag-row-even.ag-row-level-0 .ag-cell.cell-col-0');
var firstCell = firstColumnCells[0];
//remove potential focus on rows
for (var i = 0; i < rows.length; i++)
{
rows[i].classList.remove('ag-row-focus');
rows[i].classList.add('ag-row-no-focus');
}
//remove potential focus on first column cells
for (var j = 0; j < rows.length; j++)
{
firstColumnCells[j].classList.remove('ag-cell-focus');
firstColumnCells[j].classList.add('ag-cell-no-focus');
}
//focus first row
firstRow.classList.remove('ag-row-no-focus');
firstRow.classList.add('ag-row-focus');
//focus first cell
firstCell.classList.remove('ag-cell-no-focus');
firstCell.classList.add('ag-cell-focus');
firstCell.focus();
};
Existing issue on github : https://github.com/ceolter/ag-grid/issues/183