我使用SPServices进行自动完成,可以从不同的列表中提取。然而,我找不到的一个列表是“标签”或“标签”列表。有谁知道它在哪里,所以我可以直接从它查询?谢谢你,让我知道这是否令人困惑所以我可以详细说明。
我是新来的SharePoint来自更轻的网络开发,所以请不要害怕告诉我,我也不知道我在说什么。感谢。
答案 0 :(得分:0)
使用“U2U CAML查询生成器”,看起来可以查询TaxonomyHiddenList
。这是隐藏的,所以我假设你需要“所有者”的权利,但它适用于我。
<script type="text/javascript">
$(document).ready (function() {
$().SPServices({
operation: "GetListItems",
async: true,
listName: "TaxonomyHiddenList",
CAMLViewFields: "<ViewFields>" +
"<FieldRef Name='Title' />" +
"</ViewFields>",
completefunc: AttachAutoComplete
});
});
function AttachAutoComplete(xmlResponse) {
var domElementArray = $( "[nodeName=z:row]", xmlResponse.responseXML );
var dataMap = domElementArray.map(function() {
return {
value: $(this).attr('ows_Title')
};
});
var data = dataMap.get();
$("input#inputAutoComplete").autocomplete({
source: data,
select: function(e, ui){
alert(ui.item['value']);
}
});
}
</script>
答案 1 :(得分:0)
<script type="text/javascript">
var sharePointSite = "<Site Collection URL>";
var listToSearch = "Employee"; // enter your Contacts list name here
$(document).ready(function () {
$("#Search").keyup(function (e) {
var query = $(this).val();
var lists = new SPAPI_Lists(sharePointSite);
var items = lists.getListItems(
listToSearch, // listName
'', // viewName
'', // CAML query
'<ViewFields><FieldRef Name="Title"/><FieldRef Name="Name"/></ViewFields>', // Use this option to retrieve only specific rows
10, // rowLimit
'' // queryOptions
);
if (items.status == 200) {
var rows = items.responseXML.getElementsByTagName('z:row');
var results = "<ul>";
if (rows.length > 0) {
for (var i = 0; i < rows.length; i++) {
results += "<li><a style='color:white' href='" + sharePointSite + "/Lists/" + listToSearch + "/AllItems.aspx?ID=" + rows.item(i).getAttribute('ows_ID') + "'>" + rows.item(i).getAttribute('ows_Title') + '</a></li>';
}
results += "</ul>"; }
else {
results = "";
}
suggest(results);
}
else {
alert('There was an error: ' + items.statusText);
}
}).change();
$('#suggestionsList').click(function () {
$('#Search').val($(this).text());
$('#suggestions').fadeOut();
});
});
function suggest(inputString) {
if (inputString.length == 0) {
$('#suggestions').fadeOut();
} else {
$('#suggestions').fadeIn();
$('#suggestionsList').html(inputString);
}
}
function fill(thisValue) {
$('#suggestion').val(thisValue);
setTimeout("$('#suggestions').fadeOut();", 600);
}
</script>