|
|

前台代码:
- <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>
复制代码- $('#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": " 最后一页 "
- }
- }
- });
复制代码 后台代码:
- [HttpGet]
- public JsonResult Data()
- {
- List<BLL.Models.GetDictionary> list = BLL.Until.GetUserInfo.GetUser();
- return Json(new { data = list },JsonRequestBehavior.AllowGet);
- }
复制代码 其中注意的是:dataTable默认是get请求,post会请求不到数据,然后json要设置JsonRequestBehavior.AllowGet这个允许所有get请求方式。
最后附上官方说明文档:https://datatables.net/examples/ajax/
|
上一篇:Bootstrap Datatable 简单的基本配置下一篇:因为<null>和System.DateTime之间没有隐式转换
|