2015-04-21 53 views
2

這可能是一個錯誤,因爲這是自升級Kendo庫以來的新行爲。我有Telerik的支持票。Kendo DropDownList在網格中首次點擊時打開並關閉

我有一個網格,其中一列使用客戶端模板,該模板定義了一個輸入元素,其類爲shipMethodDD。網格的數據綁定事件然後查找具有所述類的輸入元素。下拉開始就很好。問題是,用戶第一次點擊下拉菜單時,會打開並立即關閉。隨後的任何點擊都會打開它,並且會按預期保持打開狀態。我在同一頁面上的網格外部放置了一個輸入元素,它的行爲與預期相同。所以它是在網格中的問題。

@(Html.Kendo().Grid<Models.ShipmentPlanningLineModel>() 
.Name("ShipmentPlanningOrders") 
.Columns(col => 
    { 
     col.Bound(c => c.Order.ShipMethod.Name).Title("Ship Method").Width(150) 
      .ClientTemplate("<inputclass='shipMethodDD'data-group='#= Order.Guid #'data-text-field='Name'data-value-field='Guid'data-bind='#= Order.ShipMethodGuid #'value='#= Order.ShipMethodGuid #'style='width:144px;'/>"); 
    }) 
.Filterable() 
.Scrollable(s => s.Height(600)) 
.Selectable(s => s.Mode(GridSelectionMode.Single)) 
.Sortable(s => 
{ 
    s.SortMode(GridSortMode.MultipleColumn); 
    s.AllowUnsort(true); 
}) 
.Navigatable() 
.Resizable(r => r.Columns(true)) 
.DataSource(dataSource => dataSource 
     .Ajax() 
     .Read(r => 
      { 
       r.Action("Planning", "Shipping"); 
       r.Data("getShipmentPlanningParameters"); 
      }) 
     .ServerOperation(false) 
     .AutoSync(true) 
     .PageSize(25) 
    ) 
.Events(e => 
{ 
    e.DataBound("gridBound"); 
}) 

functiongridBound(e) 
{ 
vardataSource = newkendo.data.DataSource({ 
    transport: { 
     read: { 
      url: location.href.substring(0, location.href.indexOf(':')) + '://'+ location.host + '/Shipping/GetShipMethods' 
     } 
    } 
}); 
$('.shipMethodDD').each(function(idx, item) 
{ 
    $(item).kendoDropDownList({ 
     dataTextField: "Name", 
     dataValueField: "Guid", 
     dataSource: dataSource, 
     value: $(item).val(), 
     autoBind: true, 
     change: function(e) 
     { 
      varshipMethodGuid = this.value(); 
      varinput = $(this.wrapper).find('input'); 
      $(input).val(shipMethodGuid); 
      vargroup = $(input).data('group'); 
      updateShipMethod(group, shipMethodGuid); 
     } 
    }); 
}); 

kendo.ui.progress($('#ShipmentPlanningOrders'), false); 

}

回答

0

的原因的問題是,不是整個下拉列表是在細胞內部是可見的。當單擊下拉列表時,需要將該元素進行聚焦,以便它可以處理鍵盤導航功能的關鍵事件,並且在IE中對元素進行聚焦時,它會自動執行scrollIntoView,這會導致彈出窗口被關閉。這在之前的版本中沒有發生,因爲下拉列表中的一個錯誤導致元素無法聚焦,從而無法使用鍵盤導航。爲了避免該問題則應該增加列寬:

columns.Bound(c => c.Order.ShipMethod.Name).Title("Ship Method").Width(160) 

或減少輸入寬度:

.ClientTemplate("<input ... style='width:140px;' />") 

或減小柱填充:

columns.Bound(c => c.Order.ShipMethod.Name).Title("Ship Method").Width(150).HtmlAttributes(new { style="padding: 4px 3px;"}) 

,使得整個dropdownlist是可見的。

相關問題