2014-01-22 18 views
1

我正在使用編輯器模板來顯示網格中其中一列的組合框。我想從value屬性以外的模型屬性中設置組合框的初始文本。我通常可以使用Text運算符執行此操作,但由於它位於網格內,因此需要從該特定行的數據加載。這裏是我的編輯模板代碼:如何在kendo網格編輯行內設置kendo組合框的初始文本

@(Html.Kendo().ComboBoxFor(Function(x) x) _ 
.DataTextField("PartNumber") _ 
.DataValueField("PartID") _ 
.MinLength(2) _ 
.AutoBind(False) _ 
.Text( "what do I put here" ) _ 
.Filter(FilterType.StartsWith) _ 
.DataSource(Sub(dataSource) 
        dataSource _ 
        .Read(Sub(reader) 
            reader.Action("StartsWith", "Part") 
            reader.Type(HttpVerbs.Post) 
          End Sub) _ 
        .ServerFiltering(True) 
      End Sub) 
) 

回答

0

你可以調用javascript函數可以服務於你的目的

function categoryDropDownEditor(container, options) { 
     $('<input data-text-field="PartNumber" data-value-field="PartID" data-bind="value:' + options.field + '"/>') 
     .appendTo(container) 
     .kendoDropDownList({ 
      autoBind: false, 
      dataSource: data //Your Data 
      } 
     }); 
    }