如何在Office 365 SharePoint的列表中创建级联下拉列表?
例如,如果您有一个国家/地区下拉菜单并选择美国,则会列出50个州。然后,如果您选择马里兰州,您将获得该州的城市。
答案 0 :(得分:0)
您可以使用Info Path表单,它非常容易进行级联,如果您不想使用Infopath,则必须在要使用级联的表单中使用Jquery CSOM或REST API。
请通过以下链接获取更多信息:
http://www.markrackley.net/2014/05/20/cascading-drop-down-lists-in-sharepoint-office-365-using-rest/
https://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPCascadeDropdowns
答案 1 :(得分:0)
您可以使用REST API在SharePoint中实现级联下拉列表。分步文章链接:Cascading drop down in SharePoint using REST API
//Function to filter the values of Drink Types
function loadDrinkTypes(selectedDrink) {
var drinkTypeListName = "Drink Type";
var drinkTypeListURL = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + drinkTypeListName + "')/items?$select=Title,Drink/Title,Drink/Id&$expand=Drink&$filter=Drink/Title eq '" + selectedDrink + "'";
getReqData(drinkTypeListURL, function (data) {
var items = data.d.results;
if (items.length > 0) {
var optionsAsString = '<option value=""></option>';
for (var i = 0; i < items.length; i++) {
optionsAsString += "<option value='" + items[i].Title + "'>" + items[i].Title + "</option>";
}
$('select[title="Drink Type"]').html(optionsAsString);
}
},
function (data) {
//alert("Some error occurred in getting Drink Types");
});
}
//JQuery AJAX to access REST API JSON data
function getReqData(reqUrl, success, failure) {
$.ajax({
url: reqUrl,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
success(data);
},
error: function (data) {
failure(data);
}
});
}
&#13;