Resepsiyon Kodu:
- <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>
Kopya kodu- $('#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": " 最后一页 "
- }
- }
- });
Kopya kodu Arka plan Kodu:
- [HttpGet]
- public JsonResult Data()
- {
- List<BLL.Models.GetDictionary> list = BLL.Until.GetUserInfo.GetUser();
- return Json(new { data = list },JsonRequestBehavior.AllowGet);
- }
Kopya kodu dataTable'ın varsayılan olarak istek alacağını, post will request verisi vermediğini ve ardından json'un tüm get request yöntemlerine izin verecek şekilde JsonRequestBehavior.AllowGet ayarlaması gerektiğini unutmayın.
Son olarak, resmi belgeler eklenir: https://datatables.net/examples/ajax/
|