博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
datatable实例教程
阅读量:6535 次
发布时间:2019-06-24

本文共 6178 字,大约阅读时间需要 20 分钟。

网站的后台,多数是需要使用datatable来展示数据的,因为datatable的功能比较强大,可以更好的使用。

引用css

html代码

-
编号 手机号码 真实姓名 支付宝 支付宝二维码 微信 微信二维码 开户银行 银行卡号 开户人 账户余额 添加时间 操作

js代码

    

服务端代码

private object data = "";        private object result = "";        private int sEcho, iDisplayStart, iDisplayLength, sortid, count;        private bool sorttype;        protected void Page_Load(object sender, EventArgs e)        {            string act = null;            try            {                act = Request["action"].ToString();                sEcho = Convert.ToInt32(Request["sEcho"]);                iDisplayStart = Convert.ToInt32(Request["iDisplayStart"]);//开始记录数                iDisplayLength = Convert.ToInt32(Request["iDisplayLength"]);//结束记录数                if (!int.TryParse(Request["iSortCol_0"], out sortid))//按哪列来排序                {                    sortid = -1;                }                sorttype = Request["sSortDir_0"] == "asc" ? false : true;//升序还是降序                if (!string.IsNullOrEmpty(act))                {                    switch (act)                    {                        case "GetWorkerData": GetWorkerData(); break;//获取工作人员信息                    }                }                result = data;            }            catch (Exception ex)            {                result = ReturnMsg(Enum_return.失败, ex.Message, null);            }            Response.Write(result);        }        #region 获取工作人员        private void GetWorkerData()        {            //按条件搜索            string mobile = Request["mobile"];//手机号码            string realname = Request["realname"];//用户类型            string logintimestart = Request["logintimestart"];//登录时间开始            string logintimeend = Request["logintimeend"];//登录时间结束            //获取所有数据            List
list = null; IQueryable
result = Ctx.yw_houseAgent_worker; #region 排序区分 switch (sortid) { case 0: if (sorttype) result = result.OrderByDescending(c => c.workerID); else result = result.OrderBy(c => c.workerID); break; case 1: if (sorttype) result = result.OrderByDescending(c => c.mobile); else result = result.OrderBy(c => c.mobile); break; case 2: if (sorttype) result = result.OrderByDescending(c => c.realName); else result = result.OrderBy(c => c.realName); break; case 3: if (sorttype) result = result.OrderByDescending(c => c.alipay); else result = result.OrderBy(c => c.alipay); break; case 5: if (sorttype) result = result.OrderByDescending(c => c.wechat); else result = result.OrderBy(c => c.wechat); break; case 7: if (sorttype) result = result.OrderByDescending(c => c.bank); else result = result.OrderBy(c => c.bank); break; case 8: if (sorttype) result = result.OrderByDescending(c => c.bankCardNumber); else result = result.OrderBy(c => c.bankCardNumber); break; case 9: if (sorttype) result = result.OrderByDescending(c => c.bankCardName); else result = result.OrderBy(c => c.bankCardName); break; case 10: if (sorttype) result = result.OrderByDescending(c => c.fund); else result = result.OrderBy(c => c.fund); break; case 11: if (sorttype) result = result.OrderByDescending(c => c.addTime); else result = result.OrderBy(c => c.addTime); break; default: if (sorttype) result = result.OrderByDescending(c => c.workerID); else result = result.OrderBy(c => c.workerID); break; } #endregion if (!string.IsNullOrEmpty(mobile) || !string.IsNullOrEmpty(realname) || !string.IsNullOrEmpty(logintimestart) || !string.IsNullOrEmpty(logintimeend)) //搜索情况 { #region 搜索情况 if (mobile.Trim().Length > 0)//手机号码 { result = result.Where(c => c.mobile.Contains(mobile)); } if (realname.Trim().Length > 0)//姓名 { result = result.Where(c => c.realName.Contains(realname)); } if (logintimestart.Trim().Length > 0 && logintimeend.Trim().Length > 0)//搜索查询时间 { DateTime bstart = Convert.ToDateTime(logintimestart); DateTime bend = Convert.ToDateTime(logintimeend); result = result.Where(c => c.addTime >= bstart && c.addTime <= bend); } #endregion } count = result.Where(c => c.serialID == CurrentSerialID && c.isDelete == false).Count(); list = result.Where(c => c.serialID == CurrentSerialID && c.isDelete == false).Skip(iDisplayStart).Take(iDisplayLength).ToList(); string str = SerializeTableData(sEcho, count, list); Response.Write(str); Response.End(); } #endregion

转载地址:http://brzdo.baihongyu.com/

你可能感兴趣的文章
volatile和synchronized的区别
查看>>
js操作listbox
查看>>
快速上手git
查看>>
10.30T2 二分+前缀和(后缀和)
查看>>
[emuch.net]MatrixComputations(7-12)
查看>>
vuex视频教程
查看>>
Java 线程 — ThreadLocal
查看>>
安居客爬虫(selenium实现)
查看>>
-----二叉树的遍历-------
查看>>
四则运算小程序测试--c++--软件工程课
查看>>
第二阶段冲刺8
查看>>
博客版权问题
查看>>
学习PrintWriter类
查看>>
emacs学习中
查看>>
Java中OOP对象和引用
查看>>
微信小程序 事件
查看>>
Eclipse自动补全设置
查看>>
lizbaka的周记
查看>>
面向对象实验四(输入输出流)
查看>>
Android 快捷小工具
查看>>