Kendo DropDownListFor Razor MVC没有填充

时间:2016-03-18 21:28:18

标签: asp.net-mvc asp.net-mvc-4 razor kendo-ui telerik

我无法让ddl填充.....我已经研究了大约3个小时。这是我的代码。我做错了什么

- name: format ZooKeeper HA state
  command: /usr/bin/hdfs zkfc -formatZK -nonInteractive
  become: yes
  become_user: hdfs
  run_once: yes

控制器:

@(Html.Kendo().DropDownListFor(m => m.Ethnicity)
    .OptionLabel("--Select--")
    .DataTextField("Description")
    .DataValueField("Id")
    .HtmlAttributes(new { style = "width: 100%; height:31px;" })
    .DataSource(source => {
        source.Read(read =>
        {
            read.Action("GetEthinicityValueSet", "HomeController").Type(HttpVerbs.Post); 
        }).ServerFiltering(false);
    })
    .Enable(true)
    .AutoBind(true)
)

这将返回Quickwatch中的数据:

[HttpPost]
public List<DTOEthnicity> GetEthinicityValueSet()
{
    ClientDB info = new ClientDB ();
    return info.GetEthnicities();
}

1 个答案:

答案 0 :(得分:1)

尝试以下:

public JsonResult GetEthinicityValueSet()
{
    ClientDB info = new ClientDB ();    
    return Json(info.GetEthnicities(), JsonRequestBehavior.AllowGet);
}