我正在尝试使用 ajax 调用将数据绑定到 Kendo Dropdown。call 成功获取数据,但 kendo 下拉菜单未显示任何数据。
JSON 对象
落下:
<div class="editor-field">
@Html.DropDownListFor(model => model.selectedWorkItem, new SelectList(Model.lstWorkItemType), "Select Below...", new { @style = "width:200px;height:20px" })
</div>
阿贾克斯调用:
<script type="text/javascript">
$(document).ready(function () {
$("#selectedProject").change(function () {
var valid = $("#selectedProject").val();
if (valid != "Select Below...") {
var procemessage = "<option value='0'> Please wait...</option>";
$("#selectedWorkItem").html(procemessage).show();
var murl = "/TFS/TFSProjectDetails/";
$.ajax({
url: murl,
data: { pName: valid },
cache: false,
type: "POST",
success: function (data) {
if (JSON.stringify(data) != "[]") {
var ddl = $('#selectedWorkItem').data("kendoDropDownList");
for (var x = 0; x < data.length; x++) {
ddl.setDataSource(data[x].Text);
}
ddl.refresh();
}
},
error: function (reponse) {
alert("error : " + reponse);
}
});
}
});
});
</script>