0
我試圖使用ajax調用將數據綁定到Kendo下拉列表。調用成功獲取數據,但是kendo下拉菜單不顯示任何數據。將數據加載到Kendo Dropdown
JSON對象
下拉:
<div class="editor-field">
@Html.DropDownListFor(model => model.selectedWorkItem, new SelectList(Model.lstWorkItemType), "Select Below...", new { @style = "width:200px;height:20px" })
</div>
Ajax調用:
<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>