You can use Content editor web part for this.
- Create a HTML file and JS file. Since you asked JavaScript then you will have 2 options
i. REST API
ii. JSOM
- You need to upload the HTML and JS files to custom Library OR to your Site assets.
- Add the content editor webpart and copy the relative URL of the html file and paste in options list. (If you want to know more about content editor web part, kindly let me know)
You can also do it from script editor web part but you should prefer Content editor for your requirement.
I can share you the code if you need for the above requirement.
Thanks,
Regards,
Sukumar MS
Kindly find code below for Get list items:
you can also do for UPDATE, DELETE and INSERT operations.
function loadMyItems() {
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var oDataUrl = siteUrl + "/_api/web/lists/getbytitle('Sukumar_List')/items?$select=ID,Emp_Name,Designation,Date_x0020_of_x0020_Joining,Salary,Project_Details,Company,ReportingTo/Title,ReportingTo/Manager_Name&$expand=ReportingTo";
$.ajax({
url: oDataUrl,
type: "GET",
dataType: "json",
headers: {
"accept": "application/json;odata=verbose"
},
success: mySuccHandler,
error: myErrHandler
}
function mySuccHandler(data) {
var results = data.d.results;
var _html = "";
_html += '<table id="myTable" class="table" >';
_html += '<thead><tr><th>Employee Number</th><th>Employee Name</th><th>Designation</th><th>Date Joined</th><th>Project Details</th><th>Company Name</th><th>LookUp Refernce</th><th>People Picker</th><th>Action Item</th></tr></thead>'; // heading columns
$.each(results, function (index, dataRec) {
_html += '<tr>';
_html += '<td>' + dataRec.ID + '</td>'; //columns
_html += '<td>' + dataRec.Emp_Name + '</td>';
_html += '<td>' + dataRec.Designation + '</td>';
_html += '<td>' + dataRec.Date_x0020_of_x0020_Joining + '</td>';
_html += '<td>' + dataRec.Project_Details + '</td>';
_html += '<td>' + dataRec.Company + '</td>';
_html += '<td>' + dataRec.ReportingTo.Manager_Name + '</td>';
_html += '<td></td>';
// _html += '<td>' + peoplePicker(dataRec.ID) + '</td>';
_html += '<td> <span class="glyphicon glyphicon-pencil"> </span><a href="javascript:void(0)" role="button" onclick="editItem(this)" >EDIT </a><span class="glyphicon glyphicon-remove"><a href="javascript:void(0)" role="button" onclick="deleteItem(\'' + dataRec.ID + '\')"> DELETE</a></span></td>';
_html += '</tr>';
});
_html += "</table>"
$("#resultsDiv").append(_html);
// $("#resultsDiv").append('<table id="myTable" class="table" >');
// $("#resultsDiv").append('<tr><th>Employee Number</th><th>Employee Name</th><th>Designation</th><th>Action Item</th></tr>'); // heading columns
// $.each(results, function(index, dataRec) {
// $("#resultsDiv").append('<tr>');
// $("#resultsDiv").append('<td>' + dataRec.ID + '</td>'); //columns
// $("#resultsDiv").append('<td>' + dataRec.Emp_Name + '</td>');
// $("#resultsDiv").append('<td>' + dataRec.Designation + '</td>');
// $("#resultsDiv").append('<td> <span class="glyphicon glyphicon-pencil"> </span><a href="javascript:void(0)" role="button" onclick="editItem(\''+dataRec.ID+'\')" >EDIT </a><span class="glyphicon glyphicon-remove"><a href="javascript:void(0)" role="button" onclick="deleteItem(\''+dataRec.ID+'\')" > DELETE</a></span></td>');
// $("#resultsDiv").append('</tr>');
// });
// $("#resultsDiv").append('</table>');
}
function myErrHandler(data, errMessage) {
alert("Error: " + errMessage);}
HTML:
<div id="resultDiv"></div>