Kendo DropDownList 未填充

Kendo DropDownList not populating

Kendo 由于某种原因下拉列表是空的,我不确定,下面是我的所有代码

@(Html.Kendo().DropDownList()
      .Name("parties")
      .HtmlAttributes(new { style = "width: 250px" })
      .DataTextField("Name")
      .DataValueField("PartyId")
      .DataSource(source =>
      {
          source.Read(read =>
          {
              read.Action("GetParties", "Concept");
          });
      })
)

控制器调用

public JsonResult GetParties([DataSourceRequest] DataSourceRequest request)
    {
        var parties = MiscAdapter.GetParties().Select(x => new PartyModel
        {
            Name = x.PartyName,
            PartyId = x.PartyId
        });
        return Json(parties.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }

型号

public class PartyModel
{
    public int PartyId { get; set; }
    public string Name { get; set; }
}

根据F12工具返回的数据

{"Data":[{"PartyId":1,"Name":"New Democratic Party"},{"PartyId":2,"Name":"Saskatchewan Party"},{"PartyId":3,"Name":"Liberal"},{"PartyId":4,"Name":"Green"},{"PartyId":5,"Name":"Independant"}],"Total":5,"AggregateResults":null,"Errors":null}

尽管我看不到代码或返回数据的任何内容,但下拉菜单中没有显示任何内容。

请尝试使用以下代码片段。您使用的方法用于网格数据绑定。

public JsonResult GetParties()
{
    List<PartyModel> models = new List<PartyModel>();
    models.Add(new PartyModel() { Name = "Name1", PartyId = 1 });
    models.Add(new PartyModel() { Name = "Name2", PartyId = 2 });

    return Json(models, JsonRequestBehavior.AllowGet);
}

如有任何疑问,请告诉我。