Javascript 如何填充Jason数据响应剑道下拉列表?
我有一个剑道下拉列表,我正在尝试使用ajax jason响应填充数据。不幸的是,下拉列表显示为空。你知道我错过了什么吗?你能帮忙吗 分区: 贾森回应:Javascript 如何填充Jason数据响应剑道下拉列表?,javascript,jquery,json,ajax,kendo-dropdown,Javascript,Jquery,Json,Ajax,Kendo Dropdown,我有一个剑道下拉列表,我正在尝试使用ajax jason响应填充数据。不幸的是,下拉列表显示为空。你知道我错过了什么吗?你能帮忙吗 分区: 贾森回应: data = "[{"SecurityGroupID":31,"SecurityGroupName":"Permission Testers","UserID":30,"Name":"Dawn Test'Neil"},
data = "[{"SecurityGroupID":31,"SecurityGroupName":"Permission Testers","UserID":30,"Name":"Dawn Test'Neil"},{"SecurityGroupID":31,"SecurityGroupName":"Permission Testers","UserID":213,"Name":"Dawn 2 Bates"}]"
为了解决这个问题,我稍微改变了方法,使用了数据源传输。一切正常。解决方案如下所示
function DisplayCommentDialog(EntityOrganizationID) {
var categories = $("#commentrecipients").kendoDropDownList({
optionLabel: "Select Recipients...",
dataTextField: "Name",
dataValueField: "UserID",
height: 310,
Width: "900px",
dataSource: {
transport: {
read: function (options) {
$.ajax({
url: "/Submission/SecurityGroupsUsersAccessRight",
dataType: "JSON", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
data: {
id: EntityOrganizationID
},
success: function (result) {
// notify the data source that the request succeeded
options.success(result);
},
error: function (result) {
// notify the data source that the request failed
options.error(result);
}
});
}
}
}
}).data("kendoDropDownList");
}
data = "[{"SecurityGroupID":31,"SecurityGroupName":"Permission Testers","UserID":30,"Name":"Dawn Test'Neil"},{"SecurityGroupID":31,"SecurityGroupName":"Permission Testers","UserID":213,"Name":"Dawn 2 Bates"}]"
function DisplayCommentDialog(EntityOrganizationID) {
var categories = $("#commentrecipients").kendoDropDownList({
optionLabel: "Select Recipients...",
dataTextField: "Name",
dataValueField: "UserID",
height: 310,
Width: "900px",
dataSource: {
transport: {
read: function (options) {
$.ajax({
url: "/Submission/SecurityGroupsUsersAccessRight",
dataType: "JSON", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
data: {
id: EntityOrganizationID
},
success: function (result) {
// notify the data source that the request succeeded
options.success(result);
},
error: function (result) {
// notify the data source that the request failed
options.error(result);
}
});
}
}
}
}).data("kendoDropDownList");
}