将返回的数据设置为Kendo Dropdownlist
Set the returned data to Kendo Dropdownlist
我在 ASP.Net MVC 中工作。我有一个 Kendo 的下拉列表和一个用于将数据插入数据库并将最近插入的数据设置为在 kendo dropdown.I 上选择的表单,我正在使用 angular for post 方法。
var response = $http({
method: "post",
url: loadAllProductsUrl,
data: JSON.stringify(customerdetail),
dataType: "json",
async: false
});
$('#customerModal').modal('hide');
return response.then(function (data) {
if (data != null) {
$("#customers").data("kendoDropDownList").dataSource.read();
setToDropdown(data);
}
else {
}
});
这是我的 Post 方法,我从这里 return 客户代码并将其设置到 kendo 下拉列表。
function setToDropdown(data) {
var temp = $("#customers").data("kendoDropDownList");
temp.select(function (dataItem) {
return dataItem.CustomerCode === data;
});
}
但是数据没有被设置到下拉列表中,因为 setToDropdown(data) 在 $("#customers").data("kendoDropDownList").dataSource.read() 之前执行;满载。请建议....
这对我有帮助
getCustomer(function (a) {
setTimeout(function () {
$("#customers").data("kendoDropDownList").value(data.CustomerName);
}, 100);
});
我在 ASP.Net MVC 中工作。我有一个 Kendo 的下拉列表和一个用于将数据插入数据库并将最近插入的数据设置为在 kendo dropdown.I 上选择的表单,我正在使用 angular for post 方法。
var response = $http({
method: "post",
url: loadAllProductsUrl,
data: JSON.stringify(customerdetail),
dataType: "json",
async: false
});
$('#customerModal').modal('hide');
return response.then(function (data) {
if (data != null) {
$("#customers").data("kendoDropDownList").dataSource.read();
setToDropdown(data);
}
else {
}
});
这是我的 Post 方法,我从这里 return 客户代码并将其设置到 kendo 下拉列表。
function setToDropdown(data) {
var temp = $("#customers").data("kendoDropDownList");
temp.select(function (dataItem) {
return dataItem.CustomerCode === data;
});
}
但是数据没有被设置到下拉列表中,因为 setToDropdown(data) 在 $("#customers").data("kendoDropDownList").dataSource.read() 之前执行;满载。请建议....
这对我有帮助
getCustomer(function (a) {
setTimeout(function () {
$("#customers").data("kendoDropDownList").value(data.CustomerName);
}, 100);
});