wendyhao-jquery-datatable
Version:
koa datatable wendyhao jquery datatable json
54 lines (44 loc) • 1.3 kB
Markdown
Cooperate with jquery.dataTables.min.js server returned form data tools
Html code:
Example:
<!DOCTYPE html>
<html>
<head>
<link href="css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function () {
$('#example').DataTable({
"processing": true,
"serverSide": true,
"ajax": "order/server_processing"
});
});
</script>
<title>test</title>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>age</th>
<th>amouts</th>
</tr>
</thead>
</table>
</body>
</html>
Server Url:order/server_processing.
Example:
;
const Router = require('koa-router');
const jtable=require('wendyhao-jquery-datatable');
const router = new Router();
var data = [[1,'zhangsan',24,17.5],[2,'lishi',26,25]];
router.get('/order/server_processing', (ctx) => {
jtable(ctx,data);//send to html for json
});
module.exports = router.routes();