zoukankan      html  css  js  c++  java
  • Examples--Basic initialisation

    https://datatables.net/examples/index

     

    1、Zero configuration

    $(document).ready(function() {
        $('#example').dataTable();
    } );

     

    2、Feature enable / disable

    $(document).ready(function() {
        $('#example').DataTable( {
            "paging":   false,
            "ordering": false,
            "info":     false
        } );
    } );

     

    3、Default ordering (sorting)

    $(document).ready(function() {
        $('#example').DataTable( {
            "order": [[ 3, "desc" ]]
        } );
    } );

     

    4、Multi-column ordering

    $(document).ready(function() {
        $('#example').DataTable( {
            columnDefs: [ {
                targets: [ 0 ],
                orderData: [ 0, 1 ]
            }, {
                targets: [ 1 ],
                orderData: [ 1, 0 ]
            }, {
                targets: [ 4 ],
                orderData: [ 4, 0 ]
            } ]
        } );
    } );

     

    5、Multiple tables

    $(document).ready(function() {
        $('table.display').DataTable();
    } );

     

    <table id="" class="display" style="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Tiger Nixon</td>
                    <td>System Architect</td>
                    <td>Edinburgh</td>
                    <td>61</td>
                    <td>$320,800</td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
        </table><table id="" class="display" style="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Jena Gaines</td>
                    <td>Office Manager</td>
                    <td>London</td>
                    <td>30</td>
                    <td>$90,560</td>
                </tr>            
            </tbody>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
        </table>

     

    6、Hidden columns

    $(document).ready(function() {
        $('#example').DataTable( {
            "columnDefs": [
                {
                    "targets": [ 2 ],
                    "visible": false,
                    "searchable": false
                },
                {
                    "targets": [ 3 ],
                    "visible": false
                }
            ]
        } );
    } );
    "columnDefs" : [
            {
                "orderable" : false,
                "targets" : [ 0, 1, 2, ]
            },
            {
                "visible" : false,
                "targets" : [ 0, 1 ]
            },
                                            

     

    7、Complex headers (rowspan and colspan)

    <table id="example" class="display" style="100%">
            <thead>
                <tr>
                    <th rowspan="2">Name</th>
                    <th colspan="2">HR Information</th>
                    <th colspan="3">Contact</th>
                </tr>

     

    8、DOM positioning

    $(document).ready(function() {
        $('#example').DataTable( {
            "dom": '<"top"i>rt<"bottom"flp><"clear">'
        } );
    } );

     

    9、Flexible table width

    <table id="example" class="display" style="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>

    10、State saving

    使用了翻页或者改变了每页显示数据数量,会保存在cookie中,下回访问时会显示上一次关闭页面时的内容。

    $(document).ready(function() {
        $('#example').DataTable( {
            stateSave: true
        } );
    } );

     11、Alternative pagination

    $(document).ready(function() {
        $('#example').DataTable( {
            "pagingType": "full_numbers"
        } );
    } );

    12、Scroll - vertical

    $(document).ready(function() {
        $('#example').DataTable( {
            "scrollY":        "200px",
            "scrollCollapse": true,
            "paging":         false
        } );
    } );

    13、Scroll - vertical, dynamic height

    $(document).ready(function() {
        $('#example').DataTable( {
            scrollY:        '50vh',
            scrollCollapse: true,
            paging:         false
        } );
    } );

    14、Scroll - horizontal

    $(document).ready(function() {
        $('#example').DataTable( {
            "scrollX": true
        } );
    } );

    15、Scroll - horizontal and vertical

    $(document).ready(function() {
        $('#example').DataTable( {
            "scrollY": 200,
            "scrollX": true
        } );
    } );

    16、Language - Comma decimal place

    $(document).ready(function() {
        $('#example').DataTable( {
            "language": {
                "decimal": ",",
                "thousands": "."
            }
        } );
    } );

    17、Language options

    $(document).ready(function() {
        $('#example').DataTable( {
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": "Nothing found - sorry",
                "info": "Showing page _PAGE_ of _PAGES_",
                "infoEmpty": "No records available",
                "infoFiltered": "(filtered from _MAX_ total records)"
            }
        } );
    } );
    {
        "decimal":        "",
        "emptyTable":     "No data available in table",
        "info":           "Showing _START_ to _END_ of _TOTAL_ entries",
        "infoEmpty":      "Showing 0 to 0 of 0 entries",
        "infoFiltered":   "(filtered from _MAX_ total entries)",
        "infoPostFix":    "",
        "thousands":      ",",
        "lengthMenu":     "Show _MENU_ entries",
        "loadingRecords": "Loading...",
        "processing":     "Processing...",
        "search":         "Search:",
        "zeroRecords":    "No matching records found",
        "paginate": {
            "first":      "First",
            "last":       "Last",
            "next":       "Next",
            "previous":   "Previous"
        },
        "aria": {
            "sortAscending":  ": activate to sort column ascending",
            "sortDescending": ": activate to sort column descending"
        }
    }
  • 相关阅读:
    在阿里云申请Symantec免费SSL证书操作流程
    http改造成https的实践案例
    Extjs Window用法详解 3 打印具体应用,是否关掉打印预览的界面
    【Unity_UWP】Unity 工程发布win10 UWP 时的本地文件读取 (下篇)
    【Unity_UWP】Unity 工程发布win10 UWP 时的本地文件读取 (上篇)
    打开文件或者uri的方式--------进程启动文件和启动者启动文件
    C# 各版本新特性
    iOS: 音效和音乐的播放,封装的工具类
    iOS: xcode打包上传iTunes失败,iTunes Store operation failed,this action can not complete .try again
    iOS: 详细的正则表达式
  • 原文地址:https://www.cnblogs.com/cuteguru/p/9168883.html
Copyright © 2011-2022 走看看