angular-ui/ui-grid

programmatic setting focus (gridApi.focus()) and/or setting tabIndex gridApi.setTabIndex(123)

Open

#4,149 建立於 2015年8月10日

在 GitHub 查看
 (5 留言) (0 反應) (0 負責人)JavaScript (5,395 star) (2,496 fork)batch import
good first issuegrid-cellNavtype: enhancement

描述

I like to transfer the focus in code to ui grid. (and have cell navigation work right away)

ui-grid has a ui-grid-focusser div that handles all the key bindings Problem is if i just take that div and call focus() on it then nothing happens because CellNav doesn't listen to that one at all. So i currently have to do a bit of a hack to get it all working:

                            // hack to set the lastRowCol to null
            // so that the focus call really initializes everything again
            // (else cellNav thinks nothing is changed and the wrong div has still focus) 
            $scope.gridApi.grid.cellNav.lastRowCol = null;
            $($element.find(".ui-grid-cell")[0]).find("div")[0].focus();

so i find a div where i know ui-grid does listen to (onclick and onfocus) and focus that one But before that i have to set the lastRowCol to null because else it will not work if the lastRow was already the row that now gets focus. because then ui grid doesn't do its thing (like transfering the focus to the focusser div) and cell nav doesn't work.

So it would be nice if we just had api to call focus() and then everything was initialized correctly and you can move with the cursors right away (also when the selection doesn't change) Or and maybe that is even nicer having a property tabIndex or having a public api tabIndex that ui-grid puts on on that ui-grid-focusser div (that default has -1)

That way i can just tell ui-grid where the whole grid is in the tabindex.

貢獻者指南