Wednesday, March 28, 2018

Autocomplete feature in SharePoint Online



code for Autocomplete feature in sharePoint edit column..




<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://jqueryui.com//resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
var availableTags=function() {
var results=null;
var siteurl = _spPageContextInfo.webAbsoluteUrl;
$.ajax({
async: false,
url: siteurl + "/_api/web/lists/getbytitle('listname')/items?$select=Title",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
if (data.d.results.length > 0 ) {
results=data.d.results.map(function(i){return i.Title})
}
},
error: function (data) {
alert("Error: "+ data);
}
});
return results
}();

alert(availableTags)
$("input[id^='showautocompletefield']").autocomplete({
source: availableTags
});
} );
</script>
</head>
<body>
</body>
</html>