服务器处理

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

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

NamePositionOfficeExtn.Start dateSalary
NamePositionOfficeExtn.Start dateSalary
1
2
3
4
5
6
7
$(document).ready(function() {
       $('#example').dataTable( {
           "processing": true,
           "serverSide": true,
       } );
   } );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<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