2011-07-22 46 views
4

我们在我们的应用程序中使用ExtJS4。我们有一个网格焦点问题。我们在ExtJS3中使用grid.getView().focusEl.focus()。现在看来这是行不通的。ExtJS4中的这个替代品是什么。ExtJS4中的网格焦点问题

回答

6

我已经帮你检查了ExtJS3和ExtJS4的差异,主要变化是focusEl已经从gridView元素中删除。

在ExtJS3,focusEl是在视图中的锚点链接

<div class="x-grid3-scroller" id="ext-gen10" style="width: 298px; height: 174px; "> 
    <div class="x-grid3-body" style="width:100px;" id="ext-gen12"> 
     <div class="x-grid3-row x-grid3-row-first x-grid3-row-last" style="width:100px;"> 
      <table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="width:100px;"> 
       <tbody> 
        <tr><td class="x-grid3-col x-grid3-cell x-grid3-td-0 x-grid3-cell-first " style="width: 100px;" tabindex="0"><div class="x-grid3-cell-inner x-grid3-col-0" unselectable="on">0</div></td></tr> 
       </tbody> 
      </table> 
     </div> 
    </div> 
    <a href="#" class="x-grid3-focus" tabindex="-1" id="ext-gen13"></a> 
</div> 

在ExtJS4,此锚链接不存在

这是一个小我fiddle test我已经为你创造。基本上你需要改变如下:

grid.getView().el.focus(); 

而不是获得focusEl(锚链接),我们使用整个元素。

希望这可以解决您的问题。

+0

grid.getView()。focus()也可以工作,并且可能是更干净的方法。 –