The data in dataTables has its own paging and query and its own export of excel tables

dataTable is a good front-end development tool for back-end developers. It comes with paging, querying and exporting excel and many functions. Please see the official website of datatables.



<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!-- <link rel="stylesheet" type="text/css" href="js/datatable/css/jquery.dataTables.min.css"> -->
<link rel="stylesheet" type="text/css" href="js/btu/css/buttons.dataTables.min.css" />


<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>资讯列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont"></i> 首页 <span class="c-gray en">></span> 资讯管理 <span class="c-gray en">></span> 资讯列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont"></i></a></nav>
<div class="page-container">
<div class="text-c">
<button onclick="removeIframe()" class="btn btn-primary radius">Close tab</button>
<span class="select-box inline">
<select name="" class="select">
<option value="0">All categories</option>
<option value="1">分类一</option>
<option value="2">分类二</option>
</select>
</span> Date range:
<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" class="input-text Wdate" style="width:120px;">
-
<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax" class="input-text Wdate" style="width:120px;">
<input type="text" name="" id="" placeholder=" 资讯名称" style="width:250px" class="input-text">
<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜资讯</button>
</div>
<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a> <a class="btn btn-primary radius" data-title="添加资讯" data-href="article-add.html" onclick="Hui_admin_tab(this)" href="javascript:;"><i class="Hui-iconfont"></i> 添加资讯</a></span> <span class="r">共有数据:<strong>54</strong> 条</span> </div>
<div class="mt-20">
<table  id="example" class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
<thead>
<tr class="text-c">
<th width="25"><input type="checkbox" name="" value=""></th>
<th width="80">ID</th>
<th>Title</th>
<th width="80">分类</th>
<th width="80">来源</th>
<th width="120">Update time</th>
<th width="75">Views</th>
<th width="60">Post Status</th>
<th width="120">操作</th>
</tr>
</thead>
<tbody>
<tr class="text-c">
<td><input type="checkbox" value="" name=""></td>
<td>10001</td>
<td class="text-l"><u style="cursor:pointer"  class="text-primary" onClick="method5(example)" title="查看">资讯标题</u></td>
<td>Industry News</td>
<td>H-ui</td>
<td>2014-6-11 11:11:42</td>
<td>21212</td>
<td class="td-status"><span class="label label-success radius">已发布</span></td>
<td class="f-14 td-manage"><a style="text-decoration:none" onClick="article_stop(this,'10001')" href="javascript:;" title="下架"><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="article_edit('资讯编辑','article-add.html','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="article_del(this,'10001')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a></td>
</tr>
<tr class="text-c">
<td><input type="checkbox" value="" name=""></td>
<td>10002</td>
<td class="text-l"><u style="cursor:pointer" class="text-primary" onClick="article_edit('查看','article-zhang.html','10002')" title="查看">资讯标题</u></td>
<td>Industry News</td>
<td>H-ui</td>
<td>2014-6-11 11:11:42</td>
<td>21212</td>
<td class="td-status"><span class="label label-success radius">草稿</span></td>
<td class="f-14 td-manage"><a style="text-decoration:none" onClick="article_shenhe(this,'10001')" href="javascript:;" title="审核">审核</a> <a style="text-decoration:none" class="ml-5" onClick="article_edit('资讯编辑','article-add.html','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="article_del(this,'10001')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a></td>
</tr>
</tbody>
</table>
</div>
</div>
<!--_footer is detached as a public template-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></ script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H -ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!- -/_footer is separated as a public template-->


<!--Please write the script related to this page's business below-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js" ></script> 
<script type="text/javascript" src="lib/datatables/1.10. 0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/tableExport.js"></script>
<!-- <script src="https://cdn.bootcss.com/datatables-tabletools/2.1.5/js/TableTools.min.js"></script> -->
<script type="text/javascript" src="js/datatable/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/btu/js/dataTables.buttons.min.js"></script>


 <script type="text/javascript" src="js/js/buttons.html5.js"></script>
<!--<script type="text/javascript" src="js/js/dataTables.buttons.js"></script> -->
<script type="text/javascript">$(function(){*/
/* Data appears on page load

console.log("Home page loading");
$.post("../getZxgl.do",function(data){
console.log("data数据+"+data);
$(data).each(function(i,v){ 
console.table("data"+data);
/* console.log("The value of v is "+v.dd_id); */
            /*  var a=v.ul_id; */
            var content = "<tr class='text-c'>";
            var aa="";
            /* var bb="";<input type="checkbox" value="" name=""> */
            content += "<td><input type='checkbox' value='' name=''></td>";
                content += "<td>"+1000+v.id+"</td>";
            content += "<td>"+v.biaoti+"</td>";
            content += "<td>"+v.biaoti+"</td>";
            content += "<td>"+v.biaoti+"</td>";
            content += "<td>"+v.biaoti+"</td>";
            content += "<td>"+v.biaoti+"</td>";
            /* <td class="td-status"><span class="label label-success radius">草稿</span></td> */
            content +="<td class='td-status'><span class='label label-success radius'>草稿</span></td>"
            content +="<td class='f-14 td-manage'>"
           + "<a style='text-decoration:none' onClick='article_stop(this,"+"10001"+")' href='javascript:;' title='下架'><i class='Hui-iconfont'></i></a>" 
           + "<a style='text-decoration:none' class='ml-5' onClick='article_edit("+"资讯编辑"+","+"article-add.html"+","+"10001"+")' href='javascript:;' title='编辑'><i class='Hui-iconfont'></i></a>" 
           + "<a style='text-decoration:none' class='ml-5' onClick='article_del(this,"+"10001"+")' href='javascript:;' title='删除'><i class='Hui-iconfont'></i></a>"
            +"</td>";
            content += "</tr>";
            $("tbody").append(content);  
}); 
getData();
getEx();

},"json"); 
});
/*Information search*/
function getData(){
$('#example').dataTable({
"aaSorting": [[ 1, "asc" ]],//default order
"bStateSave": false,//State save
"pading":false,
    "searching": true,
"aoColumnDefs": [
  //{"bVisible": false, "aTargets": [ 3 ]} //Control the hidden display of the column
  {"orderable":false,"aTargets":[0,8]}// Columns that do not participate in sorting
]

}); } /*info-add*/ function article_add(title,url,w,h){



var index = layer.open ({
type: 2,
title: title,
content: url
});
layer.full(index);
}
/*info-edit*/
function article_edit(title,url,id,w,h){
var index = layer.open ({
type: 2,
title: title,
content: url
});
layer.full(index);
}
/*info-delete*/
function article_del(obj,id){
layer.confirm('Confirm to delete?',function(index){
$.ajax({
type: 'POST',
url: '',
dataType: 'json',
success: function(data){
$(obj).parents("tr").remove();
layer.msg('Deleted!',{icon:1,time:1000});
},
error:function(data) {
console.log(data.msg);
},
});
});
}


/*info-review*/
function article_shenhe(obj,id){
layer.confirm('Review article?', {
btn: ['Passed','Not passed','Cancel'], 
shade: false,
closeBtn: 0
},
function(){
$(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
$(obj).remove();
layer.msg('Published', {icon:6,time:1000});
},
function(){
$(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_shenqing(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
$(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
$(obj).remove();
    layer.msg('Failed', {icon:5,time:1000});
}); } /*Information-Removal*/ function article_stop(obj,id){



layer.confirm('Confirm to be removed?',function(index){
$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_start(this,id)" href="javascript:;" title="发布"><i class="Hui-iconfont"></i></a>');
$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
$(obj).remove();
layer.msg('Unavailable!',{icon: 5,time:1000});
});
}


/*info-publish*/
function article_start(obj,id){
layer.confirm('Confirm to publish?',function(index){
$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_stop(this,id)" href="javascript:;" title="下架"><i class="Hui-iconfont"></i></a>');
$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
$(obj).remove();
layer.msg('Published!',{icon: 6,time:1000});
});
}
/*Information-Apply to go online*/
function article_shenqing(obj,id){
$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
$(obj).parents("tr").find(".td-manage").html("");
layer.msg('The application has been submitted, waiting patiently for review!', {icon: 1,time:2000});
}


//The fifth method  
 /* var idTmr;  
function getExplorer() {  
    var explorer = window.navigator. userAgent ;  
    //ie  
    if (explorer.indexOf("MSIE") >= 0) {  
        return 'ie';  
    }  
    //firefox  
    else if (explorer.indexOf("Firefox") >= 0) {  
        return 'Firefox';  
    }  
    //Chrome  
    else if(explorer.indexOf("Chrome") >= 0){  
        return 'Chrome';  
    }  
    //Opera  
    else if(explorer.indexOf("Opera") >= 0){  
        return 'Opera';    
    }  
    //Safari  
    else if(explorer.indexOf("Safari") >= 0){  
        return 'Safari';  
    }  
}  
function method5(tableid) {  
    if(getExplorer()=='ie')  
    {  
        var curTbl = document.getElementById(tableid);  
        var oXL = new ActiveXObject("Excel.Application");  
        var oWB = oXL.Workbooks.Add();  
        var xlsheet = oWB.Worksheets(1);  
        var sel = document.body.createTextRange();  
        sel.moveToElementText(curTbl);  
        sel.select();  
        sel.execCommand("Copy");  
        xlsheet.Paste();  
        oXL.Visible = true;  
        try {  
            var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");  
        } catch (e) {  
            print("Nested catch caught " + e);  
        } finally {  
            oWB.SaveAs(fname);  
            oWB.Close(savechanges = false);  
            oXL.Quit();  
            oXL = null;  
            idTmr = window.setInterval("Cleanup();", 1);  
        }  
    }  
    else  
    {  
        tableToExcel(tableid)  
    }  
}


function Cleanup() {  
    window.clearInterval(idTmr);  
    CollectGarbage();  
}  
 
var tableToExcel = (function() {  
    var uri = 'data:application/vnd.ms-excel;base64,',  
            template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>',  
            base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },  
            format = function(s, c) {  
                return s.replace(/{(\w+)}/g,  
                        function(m, p) { return c[p]; }) }  
    return function(table, name) {  
        if (!table.nodeType) table = document.getElementById(table)  
        var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}  
        window.location.href = uri + base64(format(template, ctx))  
    }  
})() */


 
   /* $(document).ready(function() {  
    $('#example').DataTable( { 
    destroy: true,
        dom: 'Bfrtip',  
       "buttons": [  
                      { "bRetrieve": true,
                          'extend': 'excel',  
                          'text': 'export',//Define the text of the export excel button  
                          'exportOptions': {  
                              'modifier': {  
                                  'page': 'current'  
                              }  
                          }  
                      }  
                  ],  
    } );  
} ); */   


 function getEx(){

$('#example').DataTable( {
destroy: true, //This sentence is very important.
        dom: 'Bfrtip',
        "bStateSave": false,  
        "bLengthChange": false,
        // Whether to enable the client state recording function. This data is recorded in cookies.
        //After opening this record, even if the page is refreshed or the browser is reopened, the previous state is preserved ------- when the value is true, aoColumnDefs cannot hide column
"sPaginationType": "full_numbers",
"oLanguage": {
"sProcessing": "Loading...",
"sLengthMenu": "Show _MENU_ records per page",
"sZeroRecords": "Sorry, the relevant data could not be queried!",
"sEmptyTable": "No data exists in the table!",
"sInfo": "Currently showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Show results 0 to 0 of 0",
"sInfoFiltered": "There are _MAX_ records in the data table",
"sSearch": "搜索:",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "Previous page",
"sNext": "Next page",
"sLast": "末页"
}
}, //Multilingual configuration
        buttons: [


'excelHtml5',
'csvHtml5',
'pdfHtml5'
              ]
    }); 


</script> 
</body>
</html>


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325815984&siteId=291194637