Display Spfield from SPList

fredericdietrich By On 29/09/2018

In javascript

function getListFields() {
var listTitle = "Pages";
var showHidden = false;
var outPut = $("#fdiOutput");
var addOutput = outPut != null && (outPut.length > 0)? true : false;
var tbl = "<table class='fdi-table'>";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('" + listTitle + "')/Fields",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
},
success: function (response) {
console.log(response);
if (addOutput)
tbl += "<tr><th>InternalName</th><th>Hidden</th><th>TypeAsString</th><th>Title</th></tr>";
for (var i = 0 ; i < response.d.results.length ; i++) {
var field = response.d.results[i];
if (!showHidden && field.Hidden) {
continue;
}
console.log(field.InternalName + " ; " + field.Hidden + " ; " + field.TypeAsString + " ; " + field.DisplayName);
if (addOutput)
tbl += '<tr><td>' + field.InternalName + '</td><td>' + field.Hidden + '</td><td>' + field.TypeAsString + '</td><td>' + field.Title + '</td></tr>';
}
tbl += "</table>";
if (addOutput)
$("#fdiOutput").append(tbl);
},
error: function (data) {
console.log("error getListFields " + listTitle);
console.log(data);
debugger;
}
});
}

get script

 

Sharepoint

  • No ratings yet - be the first to rate this.