dataTable Demo

来源:互联网 发布:东汉末年 知乎 编辑:程序博客网 时间:2024/06/05 10:50
<!-- <!doctype html><html><head><title>Cesium</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /><style>body {    font-family: sans-serif;}dt {    margin-top: 7px;}dd {    margin-top: 7px;}li {    margin-top: 3px;}ul {    list-style-type: none;}</style></head><body>  <div>    <img src="Apps/Sandcastle/images/Cesium_Logo_Color_Overlay.png" style='width: 400px' />    <ul>      <li><b>Local links</b>        <dl>          <dt>            <a href="Build/Documentation/index.html">Documentation</a>          </dt>          <dd>The complete API documentation and reference.</dd>          <dt>            <a href="Apps/HelloWorld.html">Hello World</a>          </dt>          <dd>            The simplest possible Cesium application.          </dd>          <dt>            <a href="Apps/CesiumViewer/index.html">Cesium Viewer</a>          </dt>          <dd>            A simple Cesium reference application which allows you to browse the globe and select from a variety of imagery and terrain            layers as well as load CZML, GeoJSON, and other formats supported by Cesium.          </dd>          <dt>            <a href="Apps/Sandcastle/index.html">Sandcastle</a>          </dt>          <dd>Cesium's live code editor and example gallery. Browse examples highlighting features of the Cesium API and edit and run            them all in your web browser. Cesium applications created in Sandcastle can even be saved and downloaded.</dd>        </dl>      <li><b>Unit Tests</b>        <dl>          <dt>            <a href="Specs/SpecRunner.html">Run all tests</a>          </dt>          <dt>            <a href="Specs/SpecRunner.html?webglValidation">Run with WebGL validation</a>          </dt>          <dt>            <a href="Specs/SpecRunner.html?webglStub">Run with WebGL stub</a>          </dt>          <dt>            <a href="Specs/SpecRunner.html?category=none">Select a test to run</a>          </dt>          <dt>            <a href="Specs/SpecRunner.html?category=WebGL">Run only WebGL tests</a>          </dt>          <dt>            <a href="Specs/SpecRunner.html?category=All&amp;not=WebGL">Run only non-WebGL tests</a>          </dt>        </dl></li>      <li><b>External links</b>        <dl>          <dt>            <a href="//cesiumjs.org">Homepage</a>          </dt>          <dd>The official Cesium homepage</dd>          <dt>            <a href="//cesiumjs.org/tutorials.html">Tutorials</a>          </dt>          <dd>Step by step guides for learning to use Cesium</dd>          <dt>            <a href="//cesiumjs.org/forum.html">Forum</a>          </dt>          <dd>Our forum and mailing list, questions and feedback welcome from all skill levels</dd>          <dt>            <a href="//github.com/AnalyticalGraphicsInc/cesium">GitHub</a>          </dt>          <dd>The official Cesium GitHub repository</dd>          <dt>            <a href="//cesiumjs.org/demos.html">Showcases</a>          </dt>          <dd>Demos and information about projects using Cesium</dd>          <dt>            <a href="http://webglreport.com/">WebGL Report</a>          </dt>          <dd>Provides technical information about WebGL capabilities supported by your browser</dd>        </dl></li>    </ul>  </div>  <script type="text/javascript">      if (window.location.protocol === 'file:') {          document.body.innerHTML = ""          document.write('<p><b>This file must be hosted in a web server.</br>');          document.write('See our <a href="https://cesiumjs.org/2013/04/12/Cesium-up-and-running/">Getting Started</a> ');          document.write('tutorial for a step-by-step guide.</b></p>');      }  </script></body></html> --> <!DOCTYPE html> <html lang="en"> <head>    <meta charset="UTF-8">    <title>Document</title>    <!-- 此例子是结合bootstrap的Datatables,暂且定位为最基本的例子吧 --><!-- 引入必须的css和js文件 -->  <link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />   <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/plug-ins/28e7751dbec/integration/bootstrap/3/dataTables.bootstrap.css" />   <script src="http://cdn.gbtags.com/datatables/1.10.5/js/jquery.js"></script>   <script src="http://cdn.gbtags.com/datatables/1.10.5/js/jquery.dataTables.min.js"></script>   <script type="text/javascript" language="javascript" src="http://cdn.datatables.net/plug-ins/28e7751dbec/integration/bootstrap/3/dataTables.bootstrap.js"></script>  </head> <body> <div class="domab">    <div class="" style="float:right;">        <label>            模糊查询:            <input type="text" class="dsearch" placeholder="" aria-controls="example"></label>    </div>    <button id="button" style="float:left;">删除选中的行</button>    <div style="float:left; position:relative; z-index:9999;height:100%;">        <button class="showcol">列段显示/隐藏</button>        <ul class="showul"            style=" list-style:none;display:none; position:absolute; left:80px; top:10px; background:#FFFFFF; border:1px solid #ccc; width:200px;">            <li>                <input type="checkbox" class="toggle-vis" data-column="2"/>                服务器名称            </li>            <li>                <input type="checkbox" class="toggle-vis" data-column="3"/>                IP            </li>            <li>                <input type="checkbox" class="toggle-vis" data-column="4"/>                CPU/内存            </li>            <li>                <input type="checkbox" class="toggle-vis" data-column="5"/>                数据盘大小            </li>            <li>                <input type="checkbox" class="toggle-vis" data-column="6"/>                操作系统            </li>            <li>                <input type="checkbox" class="toggle-vis" data-column="7"/>                状态            </li>        </ul>    </div>    <div style="clear:both;"></div></div><div class="wt100" style="position:relative; overflow:hidden; height:100%">    <table id="example" class="display" cellspacing="0" width="100%">        <thead>        <tr>            <th style=" width:1px; padding:0"></th>            <th style="width:30px; padding:10px 0 10px 10px">                <input type="checkbox" id="checkAll"></th>            <th>服务器名称</th>            <th>IP</th>            <th>CPU/内存</th>            <th>数据盘大小</th>            <th>操作系统</th>            <th>状态</th>        </tr>        </thead>        <tfoot>        <tr>            <th></th>            <th></th>            <th></th>            <th></th>            <th></th>            <th></th>            <th></th>            <th></th>        </tr>        </tfoot>        <tbody>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtest</a>            </td>            <td>192.168.13.7</td>            <td>3核/1G</td>            <td>5G</td>            <td>CentOS 56.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtdfest</a>            </td>            <td>192.168.136.56</td>            <td>1核/3G</td>            <td>3G</td>            <td>                <div style="height:21px; line-height:21px; overflow:hidden; width:100px;">CentO核核核核核核核核核核核核核核核核核核核核核vS                    53.5                </div>            </td>            <td>已停止</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsfdqtest</a>            </td>            <td>192.165.13.56</td>            <td>1核/16G</td>            <td>2G</td>            <td>CentOS 52.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtest</a>            </td>            <td>192.168.13.7</td>            <td>3核/1G</td>            <td>5G</td>            <td>CentOS 56.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtdfest</a>            </td>            <td>192.18.136.56</td>            <td>1核/3G</td>            <td>13G</td>            <td>CentOS 53.5</td>            <td>已停止</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsfdqtest</a>            </td>            <td>192.165.13.56</td>            <td>1核/16G</td>            <td>2G</td>            <td>CntOS 52.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtest</a>            </td>            <td>192.168.13.7</td>            <td>3核/1G</td>            <td>5G</td>            <td>CentOS 56.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">lsqtdfest</a>            </td>            <td>192.168.136.56</td>            <td>1核/3G</td>            <td>3G</td>            <td>CentOS 53.5</td>            <td>已停止</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true" onClick="clickDom(this);">aaaaaaaaaaaaaaaaaa</a>            </td>            <td>192.165.13.56</td>            <td>1核/16G</td>            <td>2G</td>            <td>CentOS 52.5</td>            <td>运行中</td>        </tr>        <tr>            <td></td>            <td>                <input type="checkbox" name="checkList"></td>            <td>                <a class="clickdom" href="javascript:;" isclick="true"                   onClick="clickDom(this);">bbbbbbbbbbbbbbbbbbbb</a>            </td>            <td>192.165.13.56</td>            <td>1核/16G</td>            <td>2G</td>            <td>CentOS 52.5</td>            <td>运行中</td>        </tr>        </tbody>    </table>    <div class="showslider">        <button class="closediv">关闭</button>    </div>    <style>        .showslider {            width: 80%;            height: 100%;            background-color: #fff;            border: 1px solid #ccc;            position: absolute;            top: 9px;        }        .addselect {            border-radius: 2px;            display: inline-block;            background-color: #ccc;            height: 12px;            width: 16px;            text-align: center;            color: #fff;            font-size: 9px;            font-family: Arial;            position: relative;            margin-left: 4px;            cursor: pointer;            overflow: hidden;            vertical-align: top;            top: 1px;        }        .addselect select {            width: 44px;            opacity: 0;            position: absolute;            left: 0;            top: 0;            cursor: pointer;        }        table.dataTable tbody th, table.dataTable th, table.dataTable tbody td {            font-size: 12px;            text-align: left;        }        table.dataTable thead th {            padding: 0 8px;        }    </style></div> </body> </html> <script type="text/javascript">        $(function () {           var table = $('#example').DataTable({               "dom": '<"top"f >rt<"bottom"ilp><"clear">',//dom定位               "dom": 'tiprl',//自定义显示项               //"dom":'<"domab"f>',               "scrollY": "220px",//dt高度               "lengthMenu": [                   [8, 6, 8, -1],                   [4, 6, 8, "All"]               ],//每页显示条数设置               "lengthChange": false,//是否允许用户自定义显示数量               "bPaginate": true, //翻页功能               "bFilter": false, //列筛序功能               "searching": true,//本地搜索               "ordering": true, //排序功能               "Info": true,//页脚信息               "autoWidth": true,//自动宽度               "oLanguage": {//国际语言转化                   "oAria": {                       "sSortAscending": " - click/return to sort ascending",                       "sSortDescending": " - click/return to sort descending"                   },                   "sLengthMenu": "显示 _MENU_ 记录",                   "sZeroRecords": "对不起,查询不到任何相关数据",                   "sEmptyTable": "未有相关数据",                   "sLoadingRecords": "正在加载数据-请等待...",                   "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录。",                   "sInfoEmpty": "当前显示0到0条,共0条记录",                   "sInfoFiltered": "(数据库中共为 _MAX_ 条记录)",                   "sProcessing": "<img src='../resources/user_share/row_details/select2-spinner.gif'/> 正在加载数据...",                   "sSearch": "模糊查询:",                   "sUrl": "",                   //多语言配置文件,可将oLanguage的设置放在一个txt文件中,例:Javascript/datatable/dtCH.txt                   "oPaginate": {                       "sFirst": "首页",                       "sPrevious": " 上一页 ",                       "sNext": " 下一页 ",                       "sLast": " 尾页 "                   }               },               "columnDefs": [                   {                       orderable: false,                       targets: 0 },                   {                       orderable: false,                       targets: 1 }               ],//第一列与第二列禁止排序               "order": [                   [0, null]               ],//第一列排序图标改为默认               initComplete: function () {//列筛选                   var api = this.api();                   api.columns().indexes().flatten().each(function (i) {                       if (i != 0 && i != 1) {//删除第一列与第二列的筛选框                           var column = api.column(i);                           var $span = $('<span class="addselect">▾</span>').appendTo($(column.header()))                           var select = $('<select><option value="">All</option></select>')                                   .appendTo($(column.header()))                                   .on('click', function (evt) {                                       evt.stopPropagation();                                       var val = $.fn.dataTable.util.escapeRegex(                                               $(this).val()                                       );                                       column                                               .search(val ? '^' + val + '$' : '', true, false)                                               .draw();                                   });                           column.data().unique().sort().each(function (d, j) {                               function delHtmlTag(str) {                                   return str.replace(/<[^>]+>/g, "");//去掉html标签                               }                               d = delHtmlTag(d)                               select.append('<option value="' + d + '">' + d + '</option>')                               $span.append(select)                           });                       }                   });               }           });           //添加索引列           table.on('order.dt search.dt',                   function () {                       table.column(0, {                           search: 'applied',                           order: 'applied'                       }).nodes().each(function (cell, i) {                           cell.innerHTML = i + 1;                       });                   }).draw();           //自定义搜索           $('.dsearch').on('keyup click', function () {               var tsval = $(".dsearch").val()               table.search(tsval, false, false).draw();           });           //checkbox全选           $("#checkAll").on("click", function () {               if ($(this).prop("checked") === true) {                   $("input[name='checkList']").prop("checked", $(this).prop("checked"));                   $('#example tbody tr').addClass('selected');               } else {                   $("input[name='checkList']").prop("checked", false);                   $('#example tbody tr').removeClass('selected');               }           });           //显示隐藏列           $('.toggle-vis').on('change', function (e) {               e.preventDefault();               console.log($(this).attr('data-column'));               var column = table.column($(this).attr('data-column'));               column.visible(!column.visible());           });           //删除选中行           $('#example tbody').on('click', 'tr input[name="checkList"]', function () {               var $tr = $(this).parents('tr');               $tr.toggleClass('selected');               var $tmp = $('[name=checkList]:checkbox');               $('#checkAll').prop('checked', $tmp.length == $tmp.filter(':checked').length);           });           $('#button').click(function () {               table.row('.selected').remove().draw(false);           });           $('.showcol').click(function () {               $('.showul').toggle();           })           //获取表格宽度赋值给右侧弹出层           wt = $('.wt100').width();           $('.showslider').css('right', -wt);           //关闭右侧弹出层           $('.closediv').click(function () {               $(this).parent('.showslider').animate({                   right: -wt               }, 200)               $('.clickdom').attr('isclick', true)           });       })       //右侧弹出详情层       /*  var flag=false;        function clickDom(obj){        var  $par=$(obj).parents('#example_wrapper').siblings('.showslider')        var  isattr=$(obj).attr('isclick');        if(isattr=="true"){        if(flag){        $par.animate({        right:-wt        },200)        flag=!flag        }        else{        $par.animate({        right:0        },200)        flag=!flag        }        }        $('.clickdom').attr('isclick',false)        $(obj).attr('isclick',true)        }        */       function clickDom(obj) {           var $par = $(obj).parents('#example_wrapper').siblings('.showslider')           var isattr = $(obj).attr('isclick');           if (isattr == "false") {           } else {               $par.animate({                   right: -wt               }, 200)               $par.animate({                   right: 0               }, 400)               $('.clickdom').attr('isclick', true)               $(obj).attr('isclick', false)           }       } </script>
原创粉丝点击