HTML:==================================================================

<div class="ibox-content">
                        <div class="thead">                 
                         <input placeholder="请输入搜索内容" id="strWhere" type="text" />
                        </div>
                        <table id="userlist" class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                      <th></th>
                                    <th><input type="checkbox" class="checkall" /></th>                               
                                    <th>昵称</th>
                                    <th>电话</th>
                                    <th>性别</th>
                                    <th>年龄</th>
                                    <th>注册日期</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>

JS:(注:我的jQuery DataTables已经汉化,此处不再配置oLanguage)=====================
$(function () {
   
    $('#userlist').DataTable({
        bProcessing: true, //DataTables载入数据时,是否显示‘进度’提示  
        bStateSave: false, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态  
        aLengthMenu: [10,20, 40, 60, 100, 1000], //更改显示记录数选项  
        iDisplayLength: 10, //默认显示的记录数  
        bInfo: true, //是否显示页脚信息,DataTables插件左下角显示记录数  
        bPaginate: true, //是否显示(应用)分页器  
        autoWidth: true, //是否自适应宽度  
        bScrollCollapse: true, //是否开启DataTables的高度自适应,当数据条数不够分页数据条数的时候,插件高度是否随数据条数而改变  
        sPaginationType: "full_numbers", //详细分页组,可以支持直接跳转到某页  
        bSort: false, //是否启动各个字段的排序功能  
        bFilter: false, //是否启动过滤、搜索功能        
        bServerSide: true,//开启此模式后,你对datatables的每个操作 每页显示多少条记录、下一页、上一页、排序(表头)、搜索,这些都会传给服务器相应的值。
        "ajax": {
            url: "/Ajax/UserMgrAjax.ashx?cmd=userList",
            type:"POST",
            data: { "strWhere": $('#strWhere').val() }
            
        } ,
        columns: [
            {
                "sWidth": "4%",
                "sClass": "text-center",
                "data": null, "targets": 0
            },
             {
                 "sWidth": "4%",
                 "sClass": "text-center",
                 "data": "u_id",
                 "render": function (data, type, full, meta) {//这里就是要显示的checkbox多选框了
                     return '<input type="checkbox"  class="checkchild"  value="' + data + '" />';
                 },
                 "bSortable": false
             },
              
              { "sClass": "text-center", "data": "u_name" },
             { "sClass": "text-center", "data": "u_tel" },
             {
                 "sClass": "text-center",
                 "data": "u_sex",
                 "render": function (data, type, row, meta) {
                   
                     var content = "保密";
                     if (data == "1")
                         content = "男";
                     if (data == "2")
                         content = "女";
                     return content;
                 }
                 
             },
             { "sClass": "text-center", "data": "u_age" },
             { "sClass": "text-center", "data": "u_registerdate" },
             {
                 "sClass": "text-center",
                 "data": "u_state",
                 "render": function (data, type, row, meta) {
                     var content = "非正常";
                     if (data == "0")
                         content = "正常";
                     if (data == "1")
                         content = "锁定";
                     return content;
                 }
             },
             {
                 "sClass": "text-center",
                 "data": "u_registerdate",
                 render: function (data, type, row, meta) {

return "<a title='编辑' class='glyphicon glyphicon-edit nounderline' href='javascript:editTabRow();'></a>&nbsp;";
                 }
             }
             
        ],
        fnDrawCallback: function () {
            
            var startIndex = this.api().context[0]._iDisplayStart;//获取到本页开始的条数
            this.api().column(0).nodes().each(function (cell, i) {
             //翻页序号连续
             cell.innerHTML = startIndex + i + 1;

});
        }
       
    });
    $(".checkall").click(function () {
        var check = $(this).prop("checked");
        $(".checkchild").prop("checked", check);
    });

});

.ashx.cs:==================================================================
namespace SmartAdmin.Ajax
{
    /// <summary>
    /// UserMgrAjax 的摘要说明
    /// </summary>
    public class UserMgrAjax : IHttpHandler
    {
        string info = "";
        string json = "";
        bool rbool = false;
        HttpContext context;
        JavaScriptSerializer jss = new JavaScriptSerializer();
        Dictionary<string, object> dic = new Dictionary<string, object>();
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;
            context.Response.ContentEncoding = Encoding.GetEncoding("utf-8");//避免出现乱码
            //接收浏览器 get/post 过来的参数cmd
            string cmd = context.Request["cmd"].ToString();
            switch (cmd)
            {
                case "userList": json = GetUserList();
                    break;
            }
            context.Response.Write(json);
        }
        /// <summary>
        /// 获得用户列表
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public string GetUserList()
        {
            #region ===代码===
            int totalCount = 0;//所有的
            int selCount = 0;//根据条件搜索到的
            string sqlSel = RequestHelper.GetQueryString("strWhere");
            List<t_user> list = UserDal.m_UserDal.GetList("");
            totalCount = list.Count;
            int draw = Common.Utils.ToInt(context.Request.Params["draw"]);
            int start = Common.Utils.ToInt(context.Request.Params["start"]);
            int length = Common.Utils.ToInt(context.Request.Params["length"]);
            list = UserDal.m_UserDal.GetList(sqlSel, length, (start / length) + 1);
            selCount = list.Count;
            dic.Add("draw", draw);
            dic.Add("recordsTotal", selCount);
            dic.Add("recordsFiltered", totalCount);
            dic.Add("data", list);
            return jss.Serialize(dic);
            #endregion ===代码===

}
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

jQuery DataTables 分页的更多相关文章

  1. [jQuery]jQuery DataTables插件自定义Ajax分页实现

    前言 昨天在博客园的博问上帮一位园友解决了一个问题,我觉得有必要记录一下,万一有人也遇上了呢. 问题描述 园友是做前端的,产品经理要求他使用jQuery DataTables插件显示一个列表,要实现分 ...

  2. ASP.NET MVC+EF在服务端分页使用jqGrid以及jquery Datatables的注意事项

    引言: 本人想自己个博客网站出来,技术路线是用ASN.NET MVC5+EF6(Code First)+ZUI+各种Jquery插件,有了这个想法之后就开始选择UI,看了好多bootstrap的模板之 ...

  3. jQuery DataTables插件分页允许输入页码跳转

    背景说明 项目中使用jQuery DataTables插件来实现分页表格,但是默认的分页样式不能输入页码进行跳转,在页数非常多的时候使用很不方便,最主要的还是没有达到产品部门的设计要求,所以我需要寻找 ...

  4. jquery.dataTables的探索之路-服务端分页配置

    最近闲来无事想研究下数据表格,因为之前接触过layui和bootstrap的数据表格,本着能学多少学多少的学习态度,学习下dataTables的服务端分页配置.特与同学们一块分享下从中遇到的问题和解决 ...

  5. jquery DataTables表格插件的使用(网页数据表格化及分页显示)

    DataTables - 非常强大的 jQuery 表格插件,可变宽页码浏览,现场过滤. 多列排序,自动探测数据类型,智能列宽,可从几乎任何数据源获取数据. 那么在Bootstrap下如何使用Data ...

  6. jQuery datatables

    jQuery datatables 属性,用例 参考:http://datatables.club/example/ http://blog.csdn.net/mickey_miki/article/ ...

  7. jquery.dataTable分页

    jsp页面,引入几个js <link type="text/css" rel="stylesheet" href="/library/css/b ...

  8. Jquery.Datatables 服务器处理(Server-side processing)

    看了看介绍 http://datatables.club/manual/server-side.html 没有经过处理的分页,先显示出来看看效果,就这样写(存储过程自己写) cshtml " ...

  9. Jquery DataTables相关示例

    一.Jquery-DataTables DataTables 是jquery的一个开源的插件.它具有高度灵活的特性,基于渐进增强的基础,可以为任何表格添加交互.它特性如下: 提供分页,搜索和多列排序: ...

随机推荐

  1. 【推荐系统】知乎live入门2.细节补充

    参考链接 [推荐系统]知乎live入门 目录 1. 综述 2. 召回 3. 用户画像与标签 4. 特征工程 5. 点击率预估 6. 评估 7. 数据标注 8. 推荐 ================= ...

  2. python 安装 pip ,并使用pip 安装 filetype

    闲话少说,直接上操作. python版本为2.7.6 可以直接到官网下载,我也提供一个百度云的下载地址 https://pan.baidu.com/s/1kWPXG8Z 这个是window版本,lin ...

  3. GB28181 To RTMP/HLS/HTTP-FLV/DASH Gateway

    I. Deployment  / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server https://f ...

  4. 银联银行卡查询服务-dubbo实现

    最近看到银联开放了一个银行卡查询的服务,具体内容见官网https://open.unionpay.com/tjweb/api/detail?apiSvcId=51 尝尝鲜 在文档下载目录下,下载upa ...

  5. AD转换为KiCAD的方法

    一.Altium文件转KiCad文件 本文主要介绍: 1.AD文件(SCH和PCB)转换为KiCAD的方法 2.AD封装库转换为KiCAD库的方法 下面让我们进入正题 1.1 PCB的第一种转换方式 ...

  6. 14DBCP连接池

    实际开发中“获得连接”或“释放资源”是非常消耗系统资源的两个过程,为了解决此类性能问题,通常情况我们采用连接池技术,来共享连接Connection.这样我们就不需要每次都创建连接.释放连接了,这些操作 ...

  7. nginx-博客阅读笔记记录-20190916

    Nginx 入门学习教程 Ng官网解释: nginx [engine x]是最初由Igor Sysoev编写的HTTP和反向代理服务器,邮件代理服务器和通用TCP / UDP代理服务器. 维基百科解释 ...

  8. thinkphp model

    模型样板 <?php namespace app\model; use think\Db; use think\Model; class Admin extends Model { //表名 p ...

  9. Jmeter BeanShell前置处理器、取样器、后置处理器

    前置处理器:BeanShell PreProcessor取样器 :BeanShell Sampler后置处理器:BeanShell PostProcessor 1.前置 import org.apac ...

  10. Dubbo学习-6-springboot整合dubbo

    1.在前面帖子和工程的基础上,这里使用springboot整合dubbo,首先创建springboot项目: https://start.spring.io/  进入spring Initializr ...