<html>
<head>
    <title></title>
    <script src="/jquery-easyui-1.3.4/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="/jquery-easyui-1.3.4/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/jquery-easyui-1.3.4/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <link href="/jquery-easyui-1.3.4/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="/jquery-easyui-1.3.4/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("#cc").layout();
        })
    </script>
</head>
<body>
    <div id="cc" fit="true">
        <div data-options="region:'north',title:'North Title',split:true" style="height: 100px;">
        </div>
        <div data-options="region:'south',title:'South Title',split:true" style="height: 100px;">
        </div>
        <div data-options="region:'west',title:'West',split:true" style="width: 100px;">
        </div>
        <div data-options="region:'center',title:'我是中间面板'" style="overflow:hidden;" href='/tabs/tabChild/UserManager.htm'>

</div>
    </div>
</body>
</html>

-------------------UserManager.html-------------------

<script type="text/javascript">
    $(function () {
        $("#divLayout").layout();
        $("#tblUserList").datagrid({
            url: '/ashx/UserManager.ashx',
            title: '',
            loadMsg: '数据加载中,请稍候...',
            nowrap: false,
            pageSize: 10,
            pageList: [10, 20, 30],
            columns: [[          //注意要两个嵌套的中括号
                { field: 'Id', title: '编号', width: 120, align: 'center', sortable: true },
                { field: 'LoginId', title: '用户ID', width: 120, align: 'left', sortable: true },
                { field: 'Name', title: '用户名称', width: 120, align: 'left', sortable: true },
                { field: 'Address', title: '用户地址', width: 120, align: 'left', sortable: true }
                ]],
            fitColumns: true,
            singleSelect: true,
            pagination: true,
            sortOrder: "asc",
            sortName: "Id",      //初始化时按Id升序排序
            toolbar: [{
                iconCls: 'icon-add',
                text: '添加',
                handler: function () { alert('Add') }
            }, '-', {            //分隔符
                iconCls: 'icon-edit',
                text: '编辑',
                handler: function () { alert('edit') }
            }, '-', {
                iconCls: 'icon-remove',
                text: '删除',
                handler: function () {
                    alert('delete')
                }
            }, '-', {
                iconCls: 'icon-search',
                text: '查询',
                handler: function () {
                    alert('search')
                }
            }]
        });

});

//按用户自定义查询条件查询,调用datagird的load方法,传递name查询条件
    function QueryData() {
        $("#tblUserList").datagrid("load", {
            "name":$("#tblQuery").find("input[name='txtName']").val()
        });
    }

//清除查询条件
    function ClearQuery() {
        $("#tblQuery").find("input").val("");
    }
</script>
<div id="tt" class="easyui-tabs" fit="true" border="false">
    <div title="用户管理">
        <div id="divLayout" fit="true">
            <div data-options="region:'north',split:false" style="height: 60px;padding-top:6px;" border="false">
                <!--高级查询部分-->
                <table id="tblQuery" border="0" cellspacing="0" cellpadding="0" width="100%">
                    <tr>
                        <th>
                            用户名:
                        </th>
                        <td>
                            <input name="txtName" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            注册时间:
                        </th>
                        <td>
                            <input name="txtRegStartTimeStart" class="easyui-datetimebox" editable="false" />&nbsp;至
                            <input name="txtRegStartTimeEnd" class="easyui-datetimebox" editable="false" />
                            <a class="easyui-linkbutton" data-options="iconCls:'icon-search'" src="javascript:void(0)" onclick="QueryData()" plain="true">查询</a>
                            <a class="easyui-linkbutton" data-options="iconCls:'icon-remove'" src="javascript:void(0)" onclick="ClearQuery()" plain="true">清空</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div data-options="region:'center',split:false"  border="false">
                <!--显示数据列表部分-->
                <table id="tblUserList" fit="true">
                </table>
            </div>
        </div>
    </div>
</div>

---------------------后台一般处理程序UserManager---------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;

namespace MyStartEasyUi.ashx
{
    /// <summary>
    /// UserManager 的摘要说明
    /// </summary>
    public class UserManager : IHttpHandler
    {
        UsersExtendBll bll = new UsersExtendBll();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int pageIndex = GetPageIndex(context);
            int pageSize= GetPageSize(context);
            string mySort = GetSort(context) + " " + GetOrder(context);
            string queryName = GetQueryName(context);
            string whereStr = "";
            if (!string.IsNullOrEmpty(queryName))
            {
                whereStr += " name like '%" + queryName + "%'";
            }
            DataSet dsGet = bll.GetListByPage(whereStr, mySort, (pageIndex - 1) * pageSize + 1, pageIndex * pageSize);
            List<MyBookShop.Model.Users> lst = bll.DataTableToList(dsGet.Tables[0]);
            int total = bll.GetRecordCount("");
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonStrings = js.Serialize(lst);
            string returnJson = "{\"total\":"+ total.ToString() + ",\"rows\":" + jsonStrings +"}";
   //返回Json格式total表示总数,rows表示返回的数据,这样返回才能分页
            System.Threading.Thread.Sleep(2000);
            context.Response.Write(returnJson);
        }

public bool IsReusable
        {
            get
            {
                return false;
            }
        }

public Int32 GetPageSize(HttpContext context)
        {
            try
            {
                return Int32.Parse(context.Request["rows"].ToString());
            }
            catch
            {
                return 10;
            }
        }

public string GetOrder(HttpContext context)
        {
            return context.Request.Form["order"];
        }

public string GetSort(HttpContext context)
        {
            return context.Request.Form["sort"];
        }

public string GetQueryName(HttpContext context)
        {
            return context.Request.Form["name"];
        }

public Int32 GetPageIndex(HttpContext context)
        {
            try
            {
                return Int32.Parse(context.Request["page"].ToString());
            }
            catch
            {
                return 1;
            }
        }
    }

}

JQueryEasyUI-DataGrid显示数据,条件查询,排序及分页的更多相关文章

  1. EF:分页查询 + 条件查询 + 排序

    /// <summary> /// linq扩展类---zxh /// </summary> /// <typeparam name="T">& ...

  2. yii2数据条件查询-where专题

    条件查询 $customers = Customer::find()->where($cond)->all(); $cond就是我们所谓的条件,条件的写法也根据查询数据的不同存在差异,那么 ...

  3. 关于datagrid中数据条件颜色问题

    前天公司考核中做了一个小的考核项目,在考核中一直没找到怎么设置datagrid中数据颜色的代码 他的题目是这样的: 项目资金小于50000时,项目资金数字需要红色文字显示,否则以绿色文字显示 后来找到 ...

  4. Spring Boot Jpa 多条件查询+排序+分页

    事情有点多,于是快一个月没写东西了,今天补上上次说的. JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将 ...

  5. 微信小程序云开发-数据条件查询

    一.使用where条件查询 在.get()语句之前增加.where语句实现条件查询.  二.通过doc查询单条数据 1.使用doc来查询数据库中的单条数据 2.定义一个空对象,用来展示插叙到的单条数据 ...

  6. jsp 条件查询、列表分页

    条件查询 dao //根据搜索条件筛选数据 public List<User> GetUserBySearch(String userName, String sex) throws SQ ...

  7. 10)drf 过滤器(条件查询 排序 ) 分页器

    一.群查接口各种筛选组件 数据准备 models.py class Car(models.Model): name = models.CharField(max_length=16, unique=T ...

  8. EasyUI datagrid 的多条件查询

    <script type="text/javascript">         $(function () {            $("#dg" ...

  9. dojox.grid.DataGrid显示数据的方法(转)

    第一种:数据存在本地或者已经写死的JSON对象中,不需要跟服务端进行数据传输 <%@ page language="java" contentType="text/ ...

  10. SQL必知必会02 过滤数据/条件查询

随机推荐

  1. C#应用视频教程2.2 OPENGL虚拟仿真介绍

    三维在理解了如何绘制2D元素之后,我们尝试绘制3D元素. 其实多个三角形也能够成四面体,多个长方形也能够成六面体,所以绘制3D元素的时候,只要顶点数量匹配就行了   这里我们尤其注意,我把绘制之前的三 ...

  2. UML回想-通信图

        我们对软件project这一大块的学习事实上開始的还是挺早的,而且在后来的学习过程中也不断的涉及到了这些知识. 可是,经过软考的检验来看我对软工这一块的内容掌握的实在是慘不忍睹.基本上就是一出 ...

  3. AjaxAnyWhere 实现页面局部刷新,局部分页

    这个比較jquery.单纯ajax异步简单多了.不多说了直接上代码. 须要引入:ajaxanywhere-1.2.1.jar (最新)和 /ajaxAnyWhereDemo/WebRoot/js/aa ...

  4. [odroid-pc] ubuntu12.04 64bit Android4.0.3 源码编译报错及解决的方法

    第一个错误:         host Executable: cmu2nuance (out/host/linux-x86/obj/EXECUTABLES/cmu2nuance_intermedia ...

  5. 【Oracle】在win10上安装Oracle客户端报错:[INS-13001]环境不满足最低要求

    环境:win10 64bit 客户端工具: 安装的时候报错: 解决方案: 在\client\stage\cvu目录下找到如下两个文件: 编辑这两个文件,在文件中分别添加如下内容 <OPERATI ...

  6. js中ip地址与整数的相互转换

    转载地址 //IP转成整型function _ip2int(ip) {    var num = 0;    ip = ip.split(".");    num = Number ...

  7. 【转帖】基于Zookeeper的服务注册与发现

    http://www.techweb.com.cn/network/hardware/2015-12-25/2246973.shtml 背景 大多数系统都是从一个单一系统开始起步的,随着公司业务的快速 ...

  8. 【LeetCode】81. Search in Rotated Sorted Array II (2 solutions)

    Search in Rotated Sorted Array II Follow up for "Search in Rotated Sorted Array":What if d ...

  9. IIS自定义404错误不能生效的原因

    通过IIS自定义错误信息的功能,来自定义的404错误页面. 先制作显示错误信息的htm文件404.htm(随便什么名都行),我把文件入在根目录下. 使用Url类型,设置“/404.htm ”,可以成功 ...

  10. IE提示console未定义问题解决

    在页面加入如下代码: if (!window.console || !console.firebug){    var names = ["log", "debug&qu ...