Created
March 6, 2014 18:17
-
-
Save rosieks/9396042 to your computer and use it in GitHub Desktop.
datatables scroller + initial start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title></title> | |
<script src="Scripts/jquery-2.1.0.js"></script> | |
<script src="Scripts/jquery.dataTables.js"></script> | |
<script src="Scripts/dataTables.scroller.js"></script> | |
</head> | |
<body> | |
<table> | |
<thead> | |
<tr> | |
<th>Id</th> | |
<th>Name</th> | |
</tr> | |
</thead> | |
</table> | |
<script type="text/javascript"> | |
$('table').dataTable({ | |
serverSide: true, | |
ajax: function (request, drawCallback, settings) { | |
console.log('Request data'); | |
var data = []; | |
for (var i = request.start, j = request.start + request.length; i < j; i++) { | |
data.push([ i,'Lorem ipsum ' + i ]); | |
} | |
drawCallback({ | |
draw: request.draw, | |
data: data, | |
recordsTotal: 1000, | |
recordsFiltered: 1000 | |
}); | |
}, | |
displayStart: 20, | |
deferRender: true, | |
dom: 'frtiS', | |
scrollY: '200px', | |
initComplete: function (o) { | |
o.oScroller.fnScrollToRow(20); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment