html 代码


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title> </title>
<script type="text/javascript" language="javascript" src="../Scripts/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="../Scripts/jquery-easyui-1.3.2/themes/default/easyui.css" /><link rel="stylesheet" type="text/css" href="../Scripts/jquery-easyui-1.3.2/themes/icon.css" />
<script type="text/javascript" src="../Scripts/jquery-easyui-1.3.2/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery-easyui-1.3.2/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="../Resource/Css/base.css" />
</head>
<body>
<form method="post" action="orders.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTExNjk2ODg0NDRkZCOLvqGWle7VDdkjq2dhN5yAxw6yEAPsgqeeG/+Wi49/" />
</div> <div class="aspNetHidden"> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBALt0qRkApehh7YHAq/J98ULAvDVkOYC1D/zVz5bLUZLledrbR3qxiF16rmEfvZBJPE413rxsnU=" />
</div> <script type="text/javascript">
$(function () {
$('#dataList').datagrid({
title: '订单查询',
iconCls: 'icon-save',
width: 2000,
height: window.screen.height * 0.8,
fit: false,
nowrap: false,
striped: true,
url: '../jsonData/orders.ashx',
sortName: 'ids',
sortOrder: 'ids',
remoteSort: false,
idField: 'ids',
frozenColumns: [[
{ field: 'ck', checkbox: true },
{ title: '订单号', field: 'order_no', width: 100, sortable: true },
{ title: '订单状态', field: 'order_status', width: 80, sortable: true } ]],
columns: [[ { title: '产品总额', field: 'product_total_cost', width: 60, sortable: true },
{title: '订单备注', field: 'remark', width: 100, sortable: true } ]],
onHeaderContextMenu: function (e, field) {
e.preventDefault();
if (!$('#tmenu').length) {
createColumnMenu();
}
$('#tmenu').menu('show', {
left: e.pageX,
top: e.pageY
});
},
pagination: true,
rownumbers: true,
toolbar: [{
id: 'btnadd',
text: '添加',
iconCls: 'icon-add',
handler: function () {
$('#btnsave').linkbutton('enable');
alert('add')
}
}, {
id: 'btncut',
text: '删除',
iconCls: 'icon-cut',
handler: function () {
$('#btnsave').linkbutton('enable');
alert('cut')
}
}, '-', {
id: 'btnsave',
text: '保存',
disabled: true,
iconCls: 'icon-save',
handler: function () {
$('#btnsave').linkbutton('disable');
alert('save')
}
}]
});
var p = $('#dataList').datagrid('getPager');
if (p) {
$(p).pagination({
pageSize: 10, //每页显示的记录条数,默认为10
pageList: [5, 10, 15], //可以设置每页记录条数的列表
beforePageText: '第', //页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
onBeforeRefresh: function (pageNumber, pageSize) {
alert('pageNumber:' + pageNumber + ',pageSize:' + pageSize);
alert('before refresh');
}
});
} }); function createColumnMenu() {
var tmenu = $('<div id="tmenu" style="width:100px;"></div>').appendTo('body');
var fields = $('#dataList').datagrid('getColumnFields');
for (var i = 0; i < fields.length; i++) {
$('<div iconCls="icon-ok"/>').html(fields[i]).appendTo(tmenu);
}
tmenu.menu({
onClick: function (item) {
if (item.iconCls == 'icon-ok') {
$('#dataList').datagrid('hideColumn', item.text);
tmenu.menu('setIcon', {
target: item.target,
iconCls: 'icon-empty'
});
} else {
$('#dataList').datagrid('showColumn', item.text);
tmenu.menu('setIcon', {
target: item.target,
iconCls: 'icon-ok'
});
}
}
});
} function resize() {
$('#dataList').datagrid('resize', {
width: 700,
height: 400
});
}
function showDate(val) {
if (val != null) {
val = val.replace("\/Date(", "");
val = val.replace(")/", "");
dt = new Date(Number(val));
return dt.toLocaleString();
} else {
return "";
}
}
function getProduct(val) {
var start = val.indexOf("产品属性");
if (start > 8) {
start = start - 8;
}
return val.substr(start);
} function FindData() {
$('#dataList').datagrid('load', {
order_no: $('#order_no').val()
}
);
} </script>
<div id="searchtool" style="padding: 5px">
<span>订单号:</span><input name="ctl00$ContentPlaceHolder1$order_no" type="text" id="order_no" />
<a href="javascript:FindData()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">
查询</a>
</div>
<table id="dataList">
</table> </form>
</body>
</html>

后台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using ySmtHelper.Common;
using System.Data.Linq;
using System.Web.Script.Serialization; namespace ySmtHelper.jsonData
{
/// <summary>
/// Summary description for orders
/// </summary>
public class orders : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
int page = 0;
if (context.Request.QueryString["page"] != null)
{
page = Convert.ToInt32(context.Request.QueryString["page"].ToString());
}
if (context.Request.Form["page"] != null)
{
page =Convert.ToInt32( context.Request.Form["page"].ToString());
}
int rows = 0;
if (context.Request.QueryString["rows"] != null)
{
rows =Convert.ToInt32( context.Request.QueryString["rows"].ToString());
}
if (context.Request.Form["rows"] != null)
{
rows = Convert.ToInt32(context.Request.Form["rows"].ToString());
}
context.Response.ContentType = "text/plain";
//tb_order entry = new tb_order();
//entry.buyer_name = "buyer_name";
//entry.order_no = "order_no";
//entry.order_time = DateTime.Now;
JavaScriptSerializer serializer = new JavaScriptSerializer();
//序列化
//string json = serializer.Serialize(entry);
//反序列化
//tb_order tb_order = serializer.Deserialize<tb_order>(json);
// context.Response.Write(json);
context.Response.Write(BindGrid( context, page, rows));
} public string BindGrid(HttpContext context,int pageIndex, int pageSize)
{
if (pageIndex < 1)
{
pageIndex = 1;
}
int totalcount = 0;
string out_s = ""; using (SmtDataContext db = new SmtDataContext())
{
using (var writer = File.AppendText(Log.getLogFile()))
{
db.Log = writer;
var loadOptions = new DataLoadOptions();
db.LoadOptions = loadOptions;
string orderby = "order_no"; var q_count = from c in db.tb_orders select c; if (context.Request.Form["order_no"] != null && context.Request.Form["order_no"].Length>0)
{
q_count = q_count.Where(p => p.order_no.Contains(context.Request.Form["order_no"].ToString()));
} totalcount = q_count.Count();
//Skip(100)代表跳过100行后.从第101行开始分页;
//take(10)表示多少行分页;
// 第一种 var aClass = q_count.OrderBy(p => GetPropertyValue(p, orderBy.SelectedValue.Trim())).Skip((pageIndex - 1) * pageSize).Take(pageSize);
// 第2种
var aClass = LinqOrderBy.OrderByDescending(q_count, orderby).Skip((pageIndex - 1) * pageSize).Take(pageSize);
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(aClass);
//easyui 格式 { "total":239, "rows":[ {"code":"010","name":"Name 10"} ]}
StringBuilder sb = new StringBuilder();
sb.Append("{ \"total\":" + totalcount + ", \"rows\":" + json + "}");
out_s = sb.ToString();
writer.Close();
}
}
return out_s;
} public bool IsReusable
{
get
{
return false;
}
}
}
}

easyui 通用的datagrid中如何带有查询条件分页的更多相关文章

  1. MVC+Bootstrap+Drapper使用PagedList.Mvc支持多查询条件分页

    前几天做一个小小小项目,使用了MVC+Bootstrap,以前做分页都是异步加载Mvc部分视图的方式,因为这个是小项目,就随便一点.一般的列表页面,少不了有查询条件,下面分享下Drapper+Page ...

  2. easyui combobox 在datagrid中动态加载数据

    场景:datagrid 中用编辑框修改数据,有一个列使用的combobox  在可编辑的时候需要动态绑定数据,这个数据是在根据其他条件可变的 思路:在每次开启编辑框的时候动态绑定数据, datagri ...

  3. mongodb中比较级查询条件:($lt $lte $gt $gte)(大于、小于)、查找条件

    查询表中学生年级大于20,如下: db.getCollection('student').find({'age':{'$gt':'20'}}) $lt    <   (less  than ) ...

  4. (原)强类型dataset(类型化dataset)中动态修改查询条件(不确定参数查询)

    原创博客,转载请注明:http://www.cnblogs.com/albert1017/p/3361932.html 查询时有多个参数,参数个数由客户输入决定,不能确定有多少个参数,按一般的方法每种 ...

  5. Mybatis-plus在原有的select查询语句中动态追加查询条件

    一.适用场景 1.使用了xml形式的mapper.2.不想在select查询中大量使用<if>标签来判断条件是否存在而加入条件. 二.步骤 1.自定义wrapper继承QueryWrapp ...

  6. 关键字中mysql数据库查询条件带中文无结果解决办法

    package keyword; import java.io.UnsupportedEncodingException; import java.sql.Connection; import jav ...

  7. thinkphp分页效果的制作,按查询条件分页正确做法

    PHP代码: <?php namespace Home\Controller; use Think\Controller; use Home\Clas\Cate; class IndexCont ...

  8. 【spring data jpa】带有条件的查询后分页和不带条件查询后分页实现

    一.不带有动态条件的查询 分页的实现 实例代码: controller:返回的是Page<>对象 @Controller @RequestMapping(value = "/eg ...

  9. [翻译]在ASP.NET Web API中通过OData支持查询和分页

    OData可以通过形如http://localhost/Products?$orderby=Name这样的QueryString传递查询条件.排序等.你可以在任何Web API Controller中 ...

随机推荐

  1. 微信原生支付 Native扫码支付( V3.3.7 版本)

    原文:微信原生支付 Native扫码支付( V3.3.7 版本) [尊重别人的劳动成果,转载请注明出处:一缕晨光工作室,www.wispdawn.com] 前言 辛苦研究三天,遇到各种困难,最终还是克 ...

  2. 【转】简述什么是Web服务(Web Service)技术?

          Web Service 是在 Internet 上进行分布式计算的基本构造块,是组件对象技术在 Internet 中的延伸,是一种部署在Web 上的组件.它融合了以组件为基础的开发模式和 ...

  3. 如何使用Visual Studio 2013 开发PHP5.6项目

    原文如何使用Visual Studio开发PHP项目 在windows下开发php除了记事本 DW 以及一帮Zend studio,Eclipse,NetBeans之流以外,个人感觉还是vsiual ...

  4. JS自动化测试 单元测试之Qunit

    前言 因为公司开发了一套javascript SDK需要测试,在网上找了很久,找到了JQuery团队开发的QUnit,和基于JUnit的JsUnit,还有一些还没有看,先讲讲QUnit吧 下载 登录J ...

  5. userAgent,JS这么屌的用户代理,你造吗?——判断浏览器内核、浏览器、浏览器平台、windows操作系统版本、移动设备、游戏系统

    1.识别浏览器呈现引擎 为了不在全局作用域中添加多余变量,这里使用单例模式(什么是单例模式?)来封装检测脚本.检测脚本的基本代码如下所示: var client = function() { var ...

  6. jquery抖动的按钮

    http://runjs.cn/detail/tyx8dbag //shakenum:抖动的次数,shakeDistance:抖动的距离 jQuery.fn.Shake = function (sha ...

  7. D3D 光照和材料 小样例

    1.实现一个旋转的圆柱体,体现d3d光照效果 2.程序实现 #pragma once #pragma comment(lib,"winmm.lib") #pragma commen ...

  8. jquery-制作选项卡

    强大的jquery-制作选项卡   最近在学习jquery,特地把今天写的一个选项卡源码贴出来.只是做只是梳理,大神们请不要吐槽,如果有更好的方法,欢迎指点.谢谢. css <style> ...

  9. 【转】android 欢迎界面翻页成效,仿微信第一次登陆介绍翻页界面

    android 欢迎界面翻页效果,仿微信第一次登陆介绍翻页界面 本实例做的相对比较简单主要是对翻页控件的使用,有时候想要做一些功能是主要是先了解下是否有现成的控件可以使用,做起来比较简单不用费太大的劲 ...

  10. SQL数据库面试题

    SQL数据库面试题 1.SQL SREVER中,向一个表中插入了新数据,如何快捷的得到自增量字段的当前值 这种情况其实我们经常用到,比如我们新建了一个用户,建立完用户后我们希望马上得到这个新用户的ID ...