Created
February 7, 2016 16:36
-
-
Save ShigeoTejima/5e52cd3241f69702afab to your computer and use it in GitHub Desktop.
jquery datatable - specified rows and pageinfo
This file contains hidden or 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 lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Index2</title> | |
<link rel="stylesheet" href="css/bootstrap-3.3.6.min.css"></link> | |
<link rel="stylesheet" href="css/jquery-ui.min.css"></link> | |
<link rel="stylesheet" href="css/jquery.dataTables-1.10.10.css"></link> | |
</head> | |
<body> | |
<div class="container"> | |
<p>Index</p> | |
<table id="mytable" class="display"> | |
<thead> | |
<tr> | |
<th>column 1</th> | |
<th>column 2</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Row 6 data 1</td> | |
<td>Row 6 data 2</td> | |
</tr> | |
<tr> | |
<td>Row 7 data 1</td> | |
<td>Row 7 data 2</td> | |
</tr> | |
<tr> | |
<td>Row 8 data 1</td> | |
<td>Row 8 data 2</td> | |
</tr> | |
<tr> | |
<td>Row 9 data 1</td> | |
<td>Row 9 data 2</td> | |
</tr> | |
<tr> | |
<td>Row 10 data 1</td> | |
<td>Row 10 data 2</td> | |
</tr> | |
</tbody> | |
</table> | |
<script src="js/jquery-1.11.1.min.js"></script> | |
<script src="js/bootstrap-3.3.6.min.js"></script> | |
<script src="js/jquery.tmpl-1.0.4.js"></script> | |
<script src="js/jquery-ui-1.11.4.min.js"></script> | |
<script src="js/jquery.dataTables-1.10.10.js"></script> | |
<script> | |
$(function() { | |
'use strict'; | |
$("#mytable").on("preInit.dt", function(event, settings) { | |
console.log("preInit.dt"); | |
}); | |
$("#mytable").on("init.dt", function(event, settings) { | |
console.log("init.dt"); | |
}); | |
$("#mytable").on("draw.dt", function(event, settings) { | |
console.log("draw.dt"); | |
}); | |
$("#mytable").on("page.dt", function(event, settings) { | |
console.log("page.dt"); | |
}); | |
var mytable = $("#mytable").DataTable({ | |
pageLength: 5, | |
lengthChange: false, | |
//processing: true, | |
//serverSide: true, | |
searching: false, | |
preDrawCallback: function(settings) { | |
console.log("preDrawCallback"); | |
settings.oFeatures.bServerSide = "ssp"; | |
settings.bDestroying = true; | |
settings._iDisplayStart = 5; | |
settings.iInitDisplayStart = 5; | |
settings._iRecordsDisplay = 5; | |
settings._iRecordsTotal = 10; | |
settings.fnRecordsDisplay = function() { | |
return 10; | |
}; | |
}, | |
infoCallback: function(settings, start, end, max, total, pre) { | |
console.log("infoCallback"); | |
}, | |
drawCallback: function(settings) { | |
console.log("drawCallback"); | |
} | |
}); | |
}); | |
</script> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment