DataTables & SharePoint
DataTables & SharePoint
cchin25
Posts: 1Questions: 0Answers: 0
Does anyone have an example of using DataTables with SharePoint 2010? I'm attempting to pull list data as json using the built in web services. Unfortunately I'm running on an internal environment so I can't link to an example of what I'm trying to do. I got it up to the point where i can tell DataTables is rendering, but it does not display any results.
Here is the call I'm making
[code]
$(document).ready(function () {
$.ajax({
url: "url to my web service",
type: 'GET',
dataType: 'JSON',
cache: false,
success: function (json) {
$('#example').dataTable({
"bProcessing": true,
"sAjaxSource": json,
"aoColumns": [
{ "asSorting": [ "asc" ] }
]
});
},
error: function () {
alert("Error");
}
});
});
[/code]
Thanks for any assistance.
Here is the call I'm making
[code]
$(document).ready(function () {
$.ajax({
url: "url to my web service",
type: 'GET',
dataType: 'JSON',
cache: false,
success: function (json) {
$('#example').dataTable({
"bProcessing": true,
"sAjaxSource": json,
"aoColumns": [
{ "asSorting": [ "asc" ] }
]
});
},
error: function () {
alert("Error");
}
});
});
[/code]
Thanks for any assistance.
This discussion has been closed.
Replies
[code]
$('#example').dataTable({
"bProcessing": true,
"sAjaxSource": "url to my web service",
"aoColumns": [
{ "asSorting": [ "asc" ] }
]
});
[/code]
The alternative is to pass the data in using aaData (not sAjaxSource):
[code]
$(document).ready(function () {
$.ajax({
url: "url to my web service",
type: 'GET',
dataType: 'JSON',
cache: false,
success: function (json) {
$('#example').dataTable({
"bProcessing": true,
"aaData": json,
"aoColumns": [
{ "asSorting": [ "asc" ] }
]
});
},
error: function () {
alert("Error");
}
});
});
[/code]
Allan