私は剣道のドロップダウンリストで 2 日間苦労してきましたが、正しく設定できていないようです。
@Model の現在のアイテムを表示するために剣道ドロップダウンリストを取得するにはどうすればよいですか? これは私のコードです:
@Html.TextBoxFor(model => model.ShortDescription, new { @class="wide200;" })
@(Html.Kendo().DropDownList()
.Name("importance")
.HtmlAttributes(new { style = "width: 250px" })
.DataTextField("Name")
.DataValueField("ID")
.DataSource(source => {
source.Read(read =>
{
read.Action("GetImportanceList", "Home");
})
.ServerFiltering(true);
})
.SelectedIndex(0)
)
そして私のコントローラーで:
public ActionResult GetImportanceList()
{
GenericRepository<Importance> _repository = new GenericRepository<Importance>(_context);
IEnumerable<ImportanceViewModel> list = _repository.Get().ConvertToViewModelList();
return Json(list, JsonRequestBehavior.AllowGet);
}
問題は、最初の項目に設定されている SelectedIndex(0) にあります。モデルにあるものに設定するにはどうすればよいですか? テキストボックス (コードの最初の行) に対して行うのは非常に簡単です: model => model.ShortDescription. しかし、これはドロップダウンリストに対してどのように機能するのでしょうか?
エディターの表示時に設定するだけでなく、[更新] ボタンをクリックした後に新しい選択内容をグリッドに認識させたいと考えています。
これは、グリッド ポップアップ エディターのカスタム テンプレートであることに注意してください。