2013-05-21 31 views
2

我使用淘汰賽綁定了表格數據。在這裏,我有像父母一樣的行。例如在淘汰賽中綁定兒童的設置選項卡索引

<tr> 
           <td> 
            <select data-bind="value:Required, enable:RequiredActive, attr:{tabindex: 43 * ($index() + 1) }"> 
             <option value="E">Eligible</option> 
             <option value="O">On</option> 
             <option value="F">Off</option> 
            </select> 
           </td> 
           <td> 
            <input data-bind="value:SetupTime, attr: { title: tabindex: 44 * ($index() + 1) }"/> 
            <input data-bind="value:CloseTime, attr: { title: tabindex: 45 * ($index() + 1) }" /> 
           </td> 
           <td> 
            <table> 
             <tbody data-bind="foreach: WorkSegments"> 
              <tr> 
               <td> 
                <select data-bind="options:Locations, value:Location, optionsText: 'Name', optionsValue: 'ID', attr:{tabindex: 49 * ($parentContext.$index + 1) }" > 
                </select> 
               </td> 
              </tr> 
             </tbody> 
            </table> 
           </td> 
           <td> 
            <table> 
             <tbody data-bind="foreach: WorkSegments"> 
              <tr> 
               <td> 
                <select class="combobox" data-bind="options:EmployeeRoles, value:Role, optionsText: 'Name', optionsValue: 'ID', attr:{tabindex: 49 * ($parentContext.$index + 1)}" > 
                </select> 
               </td> 
              </tr> 
             </tbody> 
            </table> 
           </td> 

          </tr> 

這裏,Location和EmployeeRole下拉列表是子級,可以在父級中多次出現。因此,當設置選項卡索引我已經使用'$ parentContext。$ index',但在運行時,對於所有的子控件我得到tabindex ='南'

我也試過用$ parent.index() ,但沒有運氣。

欣賞一些幫助

回答

3

您應該使用$parentContext.$index()不是$parent.index()

<select data-bind="options:Locations, value:Location, optionsText: 'Name', optionsValue: 'ID', attr:{tabindex: 49 * ($parentContext.$index() + 1) }" > 
                </select> 

這裏是工作示例:http://jsfiddle.net/CVL4q/

+0

thnks,即工作!我的錯誤是我使用$ parentContext。$ index而不是$ parentContext。$ index() – devC