DataTables是一个jQuery的表格插件。这是一个高度灵活的工具,依据的基础逐步增强,这将增加先进的互动控制,支持任何HTML表格

效果图

代码

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jquery.dataTables插件</title>
    <link rel="stylesheet" href="bootstrap3/dist/css/bootstrap.min.css" />
    <script src="plugins/jquery/jquery-1.10.1.min.js"></script>
    <script src="plugins/DataTables/jquery.dataTables.js"></script>
    <script src="plugins/DataTables/DT_bootstrap.js"></script>
<script>
$(function(){
         
 
//      $("#sample_1").dataTable({
//                 "bPaginate": true, //开关,是否显示分页
//                 "bInfo": true, //开关,是否显示表格的一些信息
//   //              "bFilter": true, //开关,是否启用客户端过滤器
//   //              "sDom": "<>lfrtip<>",
//   //              "bAutoWith": false,
//  //               "bDeferRender": false,
//   //              "bJQueryUI": false, //开关,是否启用JQueryUI风格
//   //              "bLengthChange": true, //开关,是否显示每页大小的下拉框
//  //               "bProcessing": true,
//   //              "bScrollInfinite": false,
//  //               "sScrollY": "800px", //是否开启垂直滚动,以及指定滚动区域大小,可设值:'disabled','2000px'
//  //               "bSort": true, //开关,是否启用各列具有按列排序的功能
//  //               "bSortClasses": true,
// //                "bStateSave": false, //开关,是否打开客户端状态记录功能。这个数据是记录在cookies中的,
// //打开了这个记录后,即使刷新一次页面,或重新打开浏览器,之前的状态都是保存下来的-  ------当值为true时aoColumnDefs不能隐藏列
// //                "sScrollX": "50%", //是否开启水平滚动,以及指定滚动区域大小,可设值:'disabled','2000%'
//  //               "aaSorting": [[0, "asc"]],
//  //               "aoColumnDefs": [{ "bVisible": false, "aTargets": [0]}],//隐藏列
// //                "sDom": '<"H"if>t<"F"if>',
// //                "bAutoWidth": false, //自适应宽度
// //                "aaSorting": [[1, "asc"]],
//  //               "sPaginationType": "full_numbers",
//                 "oLanguage": {
//                     "sProcessing": "正在加载中......",
//                     "sLengthMenu": "每页显示 _MENU_ 条记录",
//                     "sZeroRecords": "对不起,查询不到相关数据!",
//                     "sEmptyTable": "表中无数据存在!",
//                     "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
//                     "sInfoFiltered": "数据表中共为 _MAX_ 条记录",
//                     "sSearch": "搜索",
//                     "oPaginate": {
//                         "sFirst": "首页",
//                         "sPrevious": "上一页",
//                         "sNext": "下一页",
//                         "sLast": "末页"
//                     }
//                 } //多语言配置
//             });
 
 
 
 
 
var TableData = function () {
    //function to initiate DataTable
    //DataTable is a highly flexible tool, based upon the foundations of progressive enhancement,
    //which will add advanced interaction controls to any HTML table
    //For more information, please visit https://datatables.net/
    var runDataTable = function () {
            var oTable = $('#sample_1').dataTable({
                "aoColumnDefs": [{
                    "aTargets": [0]
                }],
                "aaSorting": [
                    [1, 'asc']
                ],
                "aLengthMenu": [
                    [5, 10, 15, 20, -1],
                    [5, 10, 15, 20, "All"] // change per page values here
                ],
                // 设置默认显示多少条信息
                "iDisplayLength": 10,
                "oLanguage": {
                     "sProcessing": "正在加载中......",
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                     "sZeroRecords": "对不起,查询不到相关数据!",
                     "sEmptyTable": "表中无数据存在!",
                    "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
                     "sInfoFiltered": "数据表中共为 _MAX_ 条记录",
                     "sSearch": "搜索",
                     "oPaginate": {
                        "sFirst": "首页",
                         "sPrevious": "上一页",
                         "sNext": "下一页",
                         "sLast": "末页"
                    }
                 } //多语言配置
            });
            $('#sample_1_wrapper .dataTables_filter input').addClass("form-control input-sm").attr("placeholder", "Search");
            // modify table search input
            $('#sample_1_wrapper .dataTables_length select').addClass("m-wrap small");
            // modify table per page dropdown
            //$('#sample_1_wrapper .dataTables_length select').select2();
            // initialzie select2 dropdown
            $('#sample_1_column_toggler input[type="checkbox"]').change(function () {
                /* Get the DataTables object again - this is not a recreation, just a get of the object */
                var iCol = parseInt($(this).attr("data-column"));
                var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
                oTable.fnSetColumnVis(iCol, (bVis ? false : true));
            });
        };
        return {
            //main function to initiate template pages
            init: function () {
                runDataTable();
            }
        };
    }();
 
    TableData.init();//执行
 
})
</script>
</head>
<body>
    <div class="container">
        <table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
            <thead>
                <tr>
                    <th>Browser</th>
                    <th class="hidden-xs">Creator</th>
                    <th>Cost (
                    USD)</th>
                    <th class="hidden-xs"> Software license</th>
                    <th>Current
                    layout engine</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Amaya</td>
                    <td class="hidden-xs">W3C,
                    INRIA</td>
                    <td>Free</td>
                    <td class="hidden-xs">W3C</td>
                    <td>Amaya</td>
                </tr>
                <tr>
                    <td>AOL Explorer</td>
                    <td class="hidden-xs">America Online, Inc</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Trident</td>
                </tr>
                <tr>
                    <td>Arora</td>
                    <td class="hidden-xs">Benjamin C. Meyer</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Avant</td>
                    <td class="hidden-xs">Avant Force</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Tri-engine</td>
                </tr>
                <tr>
                    <td>Camino</td>
                    <td class="hidden-xs">The Camino Project</td>
                    <td>Free</td>
                    <td class="hidden-xs">tri-license</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Chromium</td>
                    <td class="hidden-xs">Google</td>
                    <td>Free</td>
                    <td class="hidden-xs">BSD</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Dillo</td>
                    <td class="hidden-xs">The Dillo team</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>Dillo</td>
                </tr>
                <tr>
                    <td>Dooble</td>
                    <td class="hidden-xs">Dooble Team</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>ELinks</td>
                    <td class="hidden-xs">Baudis, Fonseca, <i>et al.</i></td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>built-in</td>
                </tr>
                <tr>
                    <td>Web</td>
                    <td class="hidden-xs">Marco Pesenti Gritti</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Flock</td>
                    <td class="hidden-xs">Flock Inc</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Galeon</td>
                    <td class="hidden-xs">Marco Pesenti Gritti</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Google Chrome</td>
                    <td class="hidden-xs">Google</td>
                    <td>Free</td>
                    <td class="hidden-xs">Google Chrome Terms of Service</td>
                    <td>Blink</td>
                </tr>
                <tr>
                    <td>GNU IceCat</td>
                    <td class="hidden-xs">GNU</td>
                    <td>Free</td>
                    <td class="hidden-xs">MPL</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>iCab</td>
                    <td class="hidden-xs">Alexander Clauss</td>
                    <td>$20 (Pro)</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Internet Explorer</td>
                    <td class="hidden-xs">Microsoft,
                    <br>
                    Spyglass</td>
                    <td>comes with Windows</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Trident</td>
                </tr>
                <tr>
                    <td>Internet Explorer for Mac (terminated)</td>
                    <td class="hidden-xs">Microsoft</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Tasman</td>
                </tr>
                <tr>
                    <td>K-Meleon</td>
                    <td class="hidden-xs">Dorian, KKO, <i>et al.</i></td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Konqueror</td>
                    <td class="hidden-xs">KDE</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>KHTML</td>
                </tr>
                <tr>
                    <td>Links</td>
                    <td class="hidden-xs">Patocka, <i>et al.</i></td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>built-in</td>
                </tr>
                <tr>
                    <td>Lunascape</td>
                    <td class="hidden-xs">Lunascape Corporation</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Tri-engine</td>
                </tr>
                <tr>
                    <td>Lynx</td>
                    <td class="hidden-xs">Montulli, Grobe, Rezac, <i>et al.</i></td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>built-in</td>
                </tr>
                <tr>
                    <td>Maxthon</td>
                    <td class="hidden-xs">Maxthon International Limited</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Trident</td>
                </tr>
                <tr>
                    <td>Midori</td>
                    <td class="hidden-xs">Christian Dywan, et al.</td>
                    <td>Free</td>
                    <td class="hidden-xs">LGPL</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Mosaic</td>
                    <td class="hidden-xs">Marc Andreessen and
                    Eric Bina,
                    NCSA</td>
                    <td>non-commercial use</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>built-in</td>
                </tr>
                <tr>
                    <td>Mozilla Application Suite</td>
                    <td class="hidden-xs">Mozilla Foundation</td>
                    <td>Free</td>
                    <td class="hidden-xs">tri-license</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Mozilla Firefox</td>
                    <td class="hidden-xs">Mozilla Foundation</td>
                    <td>Free</td>
                    <td class="hidden-xs">MPL</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Netscape (v.6-7) </td>
                    <td class="hidden-xs">Netscape Communications Corporation,
                    AOL</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Netscape Browser (v.8)[note 2]</td>
                    <td class="hidden-xs">Mercurial Communications for
                    AOL</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Gecko, Trident</td>
                </tr>
                <tr>
                    <td>Netscape Communicator (v.4)[note 2]</td>
                    <td class="hidden-xs">Netscape Communications</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Mosaic</td>
                </tr>
                <tr>
                    <td>Netscape Navigator (v.1-4)[note 2]</td>
                    <td class="hidden-xs">Netscape Communications</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Mosaic</td>
                </tr>
                <tr>
                    <td>Netscape Navigator 9[note 2]</td>
                    <td class="hidden-xs">Netscape Communications
                    <br>
                    (division of AOL)</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>NetSurf</td>
                    <td class="hidden-xs">The NetSurf Developers</td>
                    <td>Free</td>
                    <td class="hidden-xs">GPL</td>
                    <td>NetSurf built-in</td>
                </tr>
                <tr>
                    <td>OmniWeb</td>
                    <td class="hidden-xs">The Omni Group</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Opera</td>
                    <td class="hidden-xs">Opera Software</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Presto</td>
                </tr>
                <tr>
                    <td>Opera Mobile</td>
                    <td class="hidden-xs">Opera Software</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Presto</td>
                </tr>
                <tr>
                    <td>Origyn Web Browser</td>
                    <td class="hidden-xs">Sand-labs</td>
                    <td>Free</td>
                    <td class="hidden-xs">BSD</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>QupZilla</td>
                    <td class="hidden-xs">David Rosca</td>
                    <td>Free</td>
                    <td class="hidden-xs">GNU GPLv3</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Safari</td>
                    <td class="hidden-xs">Apple Inc.</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>SeaMonkey</td>
                    <td class="hidden-xs">SeaMonkey Council</td>
                    <td>Free</td>
                    <td class="hidden-xs">tri-license</td>
                    <td>Gecko</td>
                </tr>
                <tr>
                    <td>Shiira</td>
                    <td class="hidden-xs">Happy Macintosh Developing Team</td>
                    <td>Free</td>
                    <td class="hidden-xs">BSD</td>
                    <td>WebKit</td>
                </tr>
                <tr>
                    <td>Sleipnir</td>
                    <td class="hidden-xs">Fenrir Inc.</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Trident</td>
                </tr>
                <tr>
                    <td>Torch Browser</td>
                    <td class="hidden-xs">Torch Media</td>
                    <td>Free</td>
                    <td class="hidden-xs">Proprietary</td>
                    <td>Webkit</td>
                </tr>
                <tr>
                    <td>Uzbl</td>
                    <td class="hidden-xs">Dieter Plaetinck</td>
                    <td>Free</td>
                    <td class="hidden-xs">GNU GPLv3</td>
                    <td>Webkit</td>
                </tr>
                <tr>
                    <td>WorldWideWeb (Later renamed Nexus)</td>
                    <td class="hidden-xs">Tim Berners-Lee</td>
                    <td>Free</td>
                    <td class="hidden-xs">Public domain</td>
                    <td>NeXTSTEP built-in</td>
                </tr>
                <tr>
                    <td>w3m</td>
                    <td class="hidden-xs">Akinori Ito</td>
                    <td>Free</td>
                    <td class="hidden-xs">MIT</td>
                    <td>-</td>
                </tr>
            </tbody>
        </table>
    </div>
 
</body>
</html>

jquery.dataTables插件使用例子详解的更多相关文章

  1. jQuery延迟加载插件(Lazy Load)详解

    最 新版本的Lazy Load并不能替代你的网页.即便你使用JavaScript移除了图片的src属性,有些现代的浏览器仍然会加载图片.现在你必须修改你的html代 码,使用占位图片作为img标签的s ...

  2. jQuery Fancybox插件使用参数详解

    Fancybox的特点如下: 可以支持图片.html文本.flash动画.iframe以及ajax的支持 可以自定义播放器的CSS样式 可以以组的形式进行播放 如果将鼠标滚动插件(mouse whee ...

  3. jQuery JCrop插件的使用详解

    jQuery的一个图片剪切的一个插件, 使用插件必须条件:引入jQuery.js文件,引入jQuery.Jcrop.js文件,引入JQuery.Jcrop.css文件   1.最基本的使用方法: &l ...

  4. Jquery validate插件使用方法详解

    html: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Reg.aspx.c ...

  5. jquery zTree插件 json 数据详解

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 【转】JQuery上传插件Uploadify使用详解及错误处理

    转自:http://www.jb51.net/article/43498.htm 关于JQuery上传插件Uploadify使用详解网上一大把,基本上内容都一样.我根据网上的步骤配置完成后,会报一些错 ...

  7. jQuery插件制作方法详解

        jQuery插件制作方法详解   jquery插件给我的感觉清一色的清洁,简单.如Jtip,要使用它的功能,只需要在你的元素的class上加 上Jtip,并引入jtip.js及其样式即可以了. ...

  8. [jQuery]jQuery DataTables插件自定义Ajax分页实现

    前言 昨天在博客园的博问上帮一位园友解决了一个问题,我觉得有必要记录一下,万一有人也遇上了呢. 问题描述 园友是做前端的,产品经理要求他使用jQuery DataTables插件显示一个列表,要实现分 ...

  9. jquery $.trim()去除字符串空格详解

    jquery $.trim()去除字符串空格详解 语法 jQuery.trim()函数用于去除字符串两端的空白字符. 作用 该函数可以去除字符串开始和末尾两端的空白字符(直到遇到第一个非空白字符串为止 ...

随机推荐

  1. Php 魔术常量

    魔术常量 由于其值在程序运行过程中不允许更改,所以是常量:其值,又是运行环境不同而不现,所以叫魔术. __DIR__            当前脚本文件的路径 示例: __LINE__         ...

  2. 1_jz2440在linux下烧写裸机程序

    常用的烧写方法有: 1.使用并口工具烧写:接线(参考百问网JZ2440V2开发板使用手册),使用oflash烧写(速度比较慢),可烧写.bin文件,从新上电观察效果.可烧写u_boot. 2.使用op ...

  3. jQuery自己编写插件()

    引言: 在项目中不同页面经常要用到已经写好的交互,比如弹窗,比如下拉菜单,比如选项卡,比如删除... 此时如果每次都把代码copy一份无疑是一件比较麻烦并且无趣的事情,而且个人认为有些low了,我们可 ...

  4. C#代码分层的好处

    1.对于复杂的系统,分层让代码结构清晰,便于开发人员对系统进行整体的理解.把握.如果代码没有分层,把逻辑都写在一个方法里面的代码就好比是一本没有目录的文档,要找出其中某一节都要对全文遍览一次. 2.基 ...

  5. C# SocketHelper 源码

    玄机论坛Socket类库源码+Demo 本类库采用C# TcpLister,TcpClient高度封装,采用C# NetworkStream进行异步模式读取数据.采用C# Semaphore来进行并发 ...

  6. C# winfrom中的布局 控件Anchor和Dock的区别

    c#中的布局问题 http://hi.baidu.com/whzpower/item/57e3179cca21e1cab725317a

  7. php微信支付(仅pc端扫码支付模式二)详细步骤.----仅适合第一次做微信开发的程序员

    本人最近做了微信支付开发,是第一次接触.其中走了很多弯路,遇到的问题也很多.为了让和我一样的新人不再遇到类似的问题,我把我的开发步骤和问题写出来,以供参考. 开发时间是2016/8/10,所以微信支付 ...

  8. 部门招聘开发人员(python相关)

    岗位职责: 1.参与需求分析,产品设计,功能开发: 2.负责系统平台的日常维护: 3.与团队技术交流,共同进步 任职要求: 1.精通Python:对Python有兴趣. 2.熟悉MVC架构,精通Dja ...

  9. 《C和指针》 读书笔记 -- 第10章 结构和联合

    1.聚合数据类型能够同时存储超过一个的单独数据,c提供了两种类型的聚合数据类型,数组和结构. 2.[1] struct SIMPLE { int a; }; struct SIMPLE x; [2] ...

  10. PHP微信开发代码

    1,SAE上申请服务器 2,绑定测试账号 3,Token验证 <?php /* http://www.cnblogs.com/xrhou12326/ CopyRight 2014 All Rig ...