Koda recepcije:
- <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>
Kopiraj kodo- $('#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": " 最后一页 "
- }
- }
- });
Kopiraj kodo Ozadje kode:
- [HttpGet]
- public JsonResult Data()
- {
- List<BLL.Models.GetDictionary> list = BLL.Until.GetUserInfo.GetUser();
- return Json(new { data = list },JsonRequestBehavior.AllowGet);
- }
Kopiraj kodo Upoštevajte, da dataTable privzeto uporablja get requests, post ne bo zahteval podatkov, nato pa mora json nastaviti JsonRequestBehavior.AllowGet za dovoljenje vseh get request metod.
Nazadnje je priložena uradna dokumentacija: https://datatables.net/examples/ajax/
|