1

アクション メソッドからドロップダウン リストを設定したい。初めてビューを読み込んだときはうまくいきますが、ビューをリロードするとアクションが再度呼び出されません。

問題は、データベースから項目を削除すると、ドロップダウン リストが結果を更新しないことです。

私の見解:

 @(Html.Kendo().DropDownListFor(model => model.IdSistema)
                    .Name("ddlSystems")
                    .OptionLabel("<.. Select an item ..>")
                    .DataTextField("DescSys")
                    .DataValueField("Id")
                    .HtmlAttributes(new { Style = "Width:243px;" })
                    .DataSource(source =>
                    {
                        source.Read(read =>
                        {
                            read.Action("GetAllSystems", "Systems");
                        })
                        .ServerFiltering(true);
                    })
                    .SelectedIndex(0) 
                  ) 

私のコントローラー:

public JsonResult GetAllSystems([DataSourceRequest] DataSourceRequest request)
{ 
    var items = (from row in _SystemService.GetAll()
                 orderby row.DescSys  
                 select new { row.Id, row.DescSys });
    return Json(items, JsonRequestBehavior.AllowGet);
}

私を助けてくれてありがとう。

4

1 に答える 1

3
@(Html.Kendo().DropDownListFor(model => model.IdSistema)
                    .Name("ddlSystems")
                    .OptionLabel("<.. Select an item ..>")
                    .DataTextField("DescSys")
                    .DataValueField("Id")
                    .HtmlAttributes(new { Style = "Width:243px;" })
                    .DataSource(source =>
                    {
                        source.Read(read =>
                        {
                            read.Action("GetAllSystems", "Systems");
                            read.Type(HttpVerbs.Post);
                        })
                        .ServerFiltering(true);
                    })
                    .SelectedIndex(0) 
                  ) 

****************************************コントローラ********* ************

[HttpPost]
public JsonResult GetAllSystems([DataSourceRequest] DataSourceRequest request)
{ 
    var items = (from row in _SystemService.GetAll()
                 orderby row.DescSys  
                 select new { row.Id, row.DescSys });
    return Json(items, JsonRequestBehavior.AllowGet);
}
于 2014-05-28T16:56:13.117 に答える