我需要开发一个包含在可浮动窗口中的网格:当显示窗口时,我需要关注某一行,然后我必须使用导航键向上或向下移动。现在,我了解如何聚焦指定的行(使用 grid.getView().focusRow(index)),但是,这样做后,我无法在网格中上下移动,就好像网格失去了焦点一样.
这是代码:
var storage = Ext.create ('Ext.data.Store', {
fields: ['id', 'name'] ,
data: [
{id:0,name:'foo'} ,
{id:1,name:'boo'} ,
{id:2,name:'koo'} ,
{id:3,name:'zoo'} ,
{id:4,name:'moo'} ,
{id:5,name:'too'} ,
{id:6,name:'goo'} ,
{id:7,name:'poo'} ,
{id:8,name:'loo'} ,
{id:9,name:'roo'} ,
{id:10,name:'hoo'}
]
});
Ext.create ('Ext.grid.Panel', {
title: 'My Grid' ,
width: 300 ,
height: 200 ,
store: storage ,
renderTo: Ext.getBody () ,
columns: [{
header: 'ID' ,
dataIndex: 'id'
} , {
header: 'Name' ,
dataIndex: 'name' ,
flex: 1
}] ,
listeners: {
afterlayout: function (grid) {
var view = grid.getView ();
view.focusRow (storage.getCount () - 1);
view.highlightItem (view.getNode (storage.getCount () - 1));
}
}
});
那么,在那之后,我如何“聚焦”网格以使其可导航?