Code de la réception :
- <table id="example1" class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>站点名称</th>
- <th>站点域名</th>
- <th>认证方式</th>
- </tr>
- </thead>
- <tbody id="aaaa">
-
- </tbody>
- <tfoot>
- <tr>
- <th>Rendering engine</th>
- <th>Browser</th>
- <th>Platform(s)</th>
- </tr>
- </tfoot>
- </table>
Code de copie- $('#example1').dataTable({
- "bPaginate": true,
- "bLengthChange": false,
- "bSort": true,
- "bInfo": true,
- "bAutoWidth": false,
- "bFilter": true,
- "ajax": '/Login/Data',
- "columns": [
- { "data": "name" },
- { "data": "bewrite" },
- { "data": "Descrip{过滤}tion" }
- ],
- "oLanguage": {
- "sLengthMenu": "每页显示 _MENU_ 条记录",
- "sZeroRecords": "对不起,查询不到任何相关数据",
- "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
- "sInfoEmtpy": "找不到相关数据",
- "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
- "sProcessing": "正在加载中...",
- "sSearch": "搜索",
- "sUrl": "", //多语言配置文件,可将oLanguage的设置放在一个txt文件中,例:Javascrip{过滤}t/datatable/dtCH.txt
- "oPaginate": {
- "sFirst": "第一页",
- "sPrevious": " 上一页 ",
- "sNext": " 下一页 ",
- "sLast": " 最后一页 "
- }
- }
- });
Code de copie Code de fond :
- [HttpGet]
- public JsonResult Data()
- {
- List<BLL.Models.GetDictionary> list = BLL.Until.GetUserInfo.GetUser();
- return Json(new { data = list },JsonRequestBehavior.AllowGet);
- }
Code de copie Notez que dataTable utilise par défaut les requêtes get (get requests), post ne demande pas de données, puis json doit définir JsonRequestBehavior.AllowGet pour autoriser toutes les méthodes get request.
Enfin, la documentation officielle est jointe : https://datatables.net/examples/ajax/
|