2011-07-22 48 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()也可以工作,並且可能是更乾淨的方法。 –