Multiple DataTables on same page via Sharepoint 2013
Multiple DataTables on same page via Sharepoint 2013
teondex
Posts: 19Questions: 4Answers: 0
Hey guys,
Any idea how I can call two separate Sharepoint list to two different tables on the same page?
I currently have a JS file with the below code that works well with my TeamLinks list but I would like to add another datatable to our homepage thats linked to my Phonebook list in a different web part.
Can anyone help?
// ajax call to get the list data using REST
var call = $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('TeamLinks')/items?$top=200",
type: "GET",
dataType: "json",
headers: { Accept: "application/json;odata=verbose" } });
// this gets called when the AJAX completes.
// this populates the table created above
call.done(function (data,textStatus, jqXHR){
$('#example').dataTable({
"ordering": true,
"info": false,
"bDestroy": true,
"bProcessing": true,
"aaData": data.d.results,
"aoColumns": [
{ "mData": "Title"},
{ "mData": "Notes" },
{ "mData": "Link",
"mRender": function ( data, type, full ) {return '<a href="'+data+'" target="_blank">Here</a>';} }
],
dom: '<"top"if>rt<"bottom"lp><"clear">',
tableTools: {
"SwfPath": "/sites/XXNOC/Style Library/swf/copy_csv_xls_pdf.swf"
}
});
});
This discussion has been closed.
Replies
I resolved the issue.
I changed:
to
so that it matches my table ID.
Thanks again!