Can't get DataTables to work at all
Can't get DataTables to work at all
amccormick
Posts: 4Questions: 0Answers: 0
I'm trying to get DataTables to work in SharePoint 2010. I'm linking it to a list and trying to display the data, but before I even get to that problem I want to address that I can't even use DataTables to output a simple list in a local html page. I'm using the example given in the example section. I haven't changed anything except putting the jquery/datatables links at the top. Here is the code I'm using:
[code]
<!-- jQuery -->
<!-- DataTables CSS -->
<!-- DataTables -->
$(document).ready(function() {
$('#demo').html( '' );
$('#example').dataTable( {
"aaData": [
/* Reduced data set */
[ "Trident", "Internet Explorer 4.0", "Win 95+", 4, "X" ],
[ "Trident", "Internet Explorer 5.0", "Win 95+", 5, "C" ],
[ "Trident", "Internet Explorer 5.5", "Win 95+", 5.5, "A" ],
[ "Trident", "Internet Explorer 6.0", "Win 98+", 6, "A" ],
[ "Trident", "Internet Explorer 7.0", "Win XP SP2+", 7, "A" ],
[ "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 2", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 3", "Win 2k+ / OSX.3+", 1.9, "A" ],
[ "Webkit", "Safari 1.2", "OSX.3", 125.5, "A" ],
[ "Webkit", "Safari 1.3", "OSX.3", 312.8, "A" ],
[ "Webkit", "Safari 2.0", "OSX.4+", 419.3, "A" ],
[ "Webkit", "Safari 3.0", "OSX.4+", 522.1, "A" ]
],
"aoColumns": [
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{ "sTitle": "Grade", "sClass": "center" }
]
} );
} );
[/code]
I am saving this as test.html and opening it up in my browser and it's a blank page. I'm sure I'm doing something wrong, as I'm very new to JavaScript / jquery, so don't be too harsh. Thanks.
[code]
<!-- jQuery -->
<!-- DataTables CSS -->
<!-- DataTables -->
$(document).ready(function() {
$('#demo').html( '' );
$('#example').dataTable( {
"aaData": [
/* Reduced data set */
[ "Trident", "Internet Explorer 4.0", "Win 95+", 4, "X" ],
[ "Trident", "Internet Explorer 5.0", "Win 95+", 5, "C" ],
[ "Trident", "Internet Explorer 5.5", "Win 95+", 5.5, "A" ],
[ "Trident", "Internet Explorer 6.0", "Win 98+", 6, "A" ],
[ "Trident", "Internet Explorer 7.0", "Win XP SP2+", 7, "A" ],
[ "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 2", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 3", "Win 2k+ / OSX.3+", 1.9, "A" ],
[ "Webkit", "Safari 1.2", "OSX.3", 125.5, "A" ],
[ "Webkit", "Safari 1.3", "OSX.3", 312.8, "A" ],
[ "Webkit", "Safari 2.0", "OSX.4+", 419.3, "A" ],
[ "Webkit", "Safari 3.0", "OSX.4+", 522.1, "A" ]
],
"aoColumns": [
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{ "sTitle": "Grade", "sClass": "center" }
]
} );
} );
[/code]
I am saving this as test.html and opening it up in my browser and it's a blank page. I'm sure I'm doing something wrong, as I'm very new to JavaScript / jquery, so don't be too harsh. Thanks.
This discussion has been closed.
Replies
@amccormick - can you please link us to the page so we can take a look at it.
Allan
Unfortunately I'm working on this from my local PC, I don't have it up on anything. The page is literally blank though when I open it in IE.
Allan
I'm not linking anything else. This is the entire code. Including jquery and datatables at top, and the example datatable copied directly from datatable examples.
I've never done this before and I'm not sure if I'm forgetting to include something or if my includes are wrong.
Look at the page source for the simplest DataTable example in here, and notice the HTML tags:
, , , etc. etc.
If you really don't know rudimentary HTML, you're not likely to get more advanced concepts.
When you say it is the entire code - I presume you are making it valid HTML with the doctype, header etc.
Allan
Thanks Allan, I found out that there's an error in the version of IE I'm using, where it's not recognizing the link to jquery. So, the code is correct, IE just can't process it. I appreciate you being patient with me.