码迷,mamicode.com
首页 > 其他好文 > 详细

Examples--Basic initialisation

时间:2018-06-11 20:26:17      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:style   TE   basic   The   配置   ati   def   inf   examples   

https://datatables.net/examples/index

 

1、DataTables的默认配置

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

 

2、DataTables的一些基础属性配置

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

 

3、数据排序

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

 

4、多列排序

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

 

5、多表

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

 

<table id="" class="display" style="width: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="width: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>

 

Examples--Basic initialisation

标签:style   TE   basic   The   配置   ati   def   inf   examples   

原文地址:https://www.cnblogs.com/cuteguru/p/9168883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!