Server-side pagination with DataTable 1.9 and Twitter Bootstrap 2

Server-side pagination with DataTable 1.9 and Twitter Bootstrap 2

leeprleepr Posts: 2Questions: 0Answers: 0
edited April 2012 in General
Hi there,

I've had great success with hooking DataTables up with Twitter Bootstrap following the instructions @ http://datatables.net/blog/Twitter_Bootstrap_2. However, I am having no such luck with server-side pagination. Can someone look over this and tell me what I'm missing?

My code looks like this:
[code]

$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sAjaxSource": "http://localhost/js/test.js"
} );
} );





Rendering engine
Browser
Platform(s)
Engine version
CSS grade




Loading data from server




Rendering engine
Browser
Platform(s)
Engine version
CSS grade



[/code]

When I load it, I get an error:
[quote]DataTables warning (table id = 'example'): Requested unknown parameter '1' from the data source for row 0[/quote]

I have a static JS file I'm using to test available at http://localhost/js/test.js (creating the JSON isn't a problem - this is just a test file):

[code]
{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData": [
[
"Gecko",
"Firefox 1.0",
"Win 98+ / OSX.2+",
"1.7",
"A"
],
[
"Gecko",
"Firefox 1.5",
"Win 98+ / OSX.2+",
"1.8",
"A"
],
[
"Gecko",
"Firefox 2.0",
"Win 98+ / OSX.2+",
"1.8",
"A"
],
[
"Gecko",
"Firefox 3.0",
"Win 2k+ / OSX.3+",
"1.9",
"A"
],
[
"Gecko",
"Camino 1.0",
"OSX.2+",
"1.8",
"A"
],
[
"Gecko",
"Camino 1.5",
"OSX.3+",
"1.8",
"A"
],
[
"Gecko",
"Netscape 7.2",
"Win 95+ / Mac OS 8.6-9.2",
"1.7",
"A"
],
[
"Gecko",
"Netscape Browser 8",
"Win 98SE+",
"1.7",
"A"
],
[
"Gecko",
"Netscape Navigator 9",
"Win 98+ / OSX.2+",
"1.8",
"A"
],
[
"Gecko",
"Mozilla 1.0",
"Win 95+ / OSX.1+",
"1",
"A"
]
]
}
[/code]

If anyone has any tips, they'd be greatly appreciated!

Replies

  • allanallan Posts: 63,262Questions: 1Answers: 10,423 Site admin
    Does it work on first load and then not subsequently? The thing to bare in mind here is that you are working with a static file, but DataTables is expecting the content to be dynamic - particularly sEcho which should increment on every draw. If it doesn't then DataTables gets confused since you are giving it data for a different draw and will throw an error - such as that which you are seeing.

    Allan
  • leeprleepr Posts: 2Questions: 0Answers: 0
    Thanks for your reply.

    [quote]Does it work on first load and then not subsequently?[/quote]

    Nope - it fails with that error on the first attempt. Even though it's static, it should render the first page of results... right?
  • allanallan Posts: 63,262Questions: 1Answers: 10,423 Site admin
    Yes it should. Could you run your table through the debugger please: http://debug.datatables.net ?

    Allan
This discussion has been closed.