1.目的
用漂亮的前端表格直观显示数据
2. JqueryTable简介
JqueryTable官网
表格显示
3.用法
1.初始化html页面
设置一个table
-
<table id="table_id" class="display">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2.引入静态资源
这个是JqueryTable必要的静态资源
-
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
-
-
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
如果你使用了js, 那么还需要引入jquery.js
3.初始化表格
-
$(document).ready( function () {
-
$('#table_id').DataTable();
-
3.实例
1. html页面
-
<table id="tbl_grantedCoach" class="table table-striped table-bordered nowrap" style="table-layout:fixed; text-align: center;">
-
-
-
-
-
-
-
-
<th width="12%">教员类型</th>
-
-
-
-
-
-
2.js代码
ajax 发送请求, 接受表格数据,再填写进去
-
initGrantedCoachGrid:function(){
-
-
-
grantedCoachGrid.ajax.url(
-
"course/getGrantedCoachByFolder?json&folderId="
-
+ selectNodeId + "").load();
-
-
grantedCoachGrid = $('#tbl_grantedCoach')
-
-
-
"lengthMenu" : [ [ 10, 20, 30 ],
-
-
-
-
-
-
-
-
-
-
"url" : "course/getGrantedCoachByFolder?json&folderId="
-
-
-
-
"contentType" : "application/json; charset=utf-8",
-
-
-
"rowCallback" : function(row, data) {
-
selectedUserId.push(data.userId);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
"mRender" : function(data,
-
-
-
-
} else if (data == "F") {
-
-
-
-
-
-
-
-
-
-
-
{ "data": "coachType" , "mRender":function(data,type,full){
-
-
-
-
-
-
-
-
-
-
-
-
-
"data" :function( row, type, val, meta ){
-
-
return row.userRoles[0].roleName;
-
-
-
-
-
-
-
-
-
"mRender" : function(data,
-
-
-
-
-
-
-
-
"sProcessing" : "正在加载中......",
-
"sLengthMenu" : "每页显示_MENU_条记录",
-
"sZeroRecords" : "对不起,查询不到相关数据!",
-
"sEmptyTable" : "无数据存在!",
-
"sInfo" : "当前显示_START_到_END_条,共_TOTAL_条记录",
-
"sInfoFiltered" : "数据表中共为 _MAX_ 条记录",
-
-
-
-
-
-
-
-
-
-
-
-
-
-