I am using SPServices to do autocomplete and can pull from different lists. The one list I cannot find however is the "Tag" or "Tags" list. Does anyone know where it is so I can query directly from it? Thank you and let me know if this is confusing so I can elaborate.
I开发者_Go百科m new at SharePoint coming from much lighter web dev so please dont be afraid to tell me I dont know what I am talking about too. Thanks.
Using the "U2U CAML Query Builder", it looks like there is the TaxonomyHiddenList
which can be queried against. It is hidden so I am assuming you need "owner" rights but it works for me.
<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>
<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>
精彩评论