服务器处理

Datatables有许多方法来获取你的数据,如果你的数据量比较大,这个时候你需要使用服务器模式来处理你的数据。 在服务器模式下,所有的分页,搜索,排序等操作,Datatables都会交给服务器去处理。所以每次绘制Datatables, 都会请求一次服务器获取需要的数据。

通过配置serverSideDT 这个属性来打开Datatables的服务器模式,下面的例子展示了Datatables打开服务器模式。

Name Position Office Extn. Start date Salary
Name Position Office Extn. Start date Salary
 $(document).ready(function() {
        $('#example').dataTable( {
            "processing": true,
            "serverSide": true,
            "ajax": "http://dt.thxopen.com/example/resources/server_processing_customCUrl.php"
        } );
    } );
<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
    </table>

http://datatables.net/examples/data_sources/server_side.html

Translation from DataTables.net, with permission