2016-04-05 21 views
0

クライアントテンプレートにドロップダウンリストを追加しようとしていますが、どういうわけかできない人が私を助けてくれますか?クライアント詳細テンプレートのドロップダウンリスト - 剣道グリッド

columns.Bound(o => o.ImportFunctionText).ClientTemplate("# if (ImportFunction == 0) { # Account # } else if (ImportFunction == 1) { # Row # } #") 
         .EditorTemplateName("DropDownList") 
         .EditorViewData(new 
         { 
          Id = "ImportFunction", 
          Data = ViewBag.dropDownList, 
          FieldName = "value:ImportFunction" 
         }) 
         .Width(210) 
         .Title("Function"); 

ありがとうございます。

答えて

0

エディタテンプレートを使用するには、〜/ Views/Shared/EditorTemplates/tmp_dropdown_attribute.cshtmlフォルダ内にエディタテンプレートを保存する必要があります。

@(Html.Kendo().DropDownList() 
.Name("Employee") // Name of the widget should be the same as the name of the property 
.DataValueField("EmployeeID") // The value of the dropdown is taken from the EmployeeID property 
.DataTextField("EmployeeName") // The text of the items is taken from the EmployeeName property 
.BindTo((System.Collections.IEnumerable)ViewData["employees"]) // A list of all employees which is populated in the controller 

をして、あなたのコントローラのようなビューを生成するコントローラメソッド内のViewDataコンテナをバインドする必要があります。

telerikのASPネットMVCのドキュメントによると、あなたは、テンプレートには、次のようになります。そのさらなる読書のための

public ActionResult Index() 
{ 
ViewData["employees"] = new NorthwindDataContext() 
      .Employees 
      .Select(e => new Employee 
      { 
        EmployeeID = e.EmployeeID, 
        EmployeeName = e.FirstName + " " + e.LastName 
      }) 
      .OrderBy(e => e.EmployeeName); 

return View(); 
} 

ここで見つけることができるドキュメントを参照してください。 http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates

関連する問題