asp.net与JQuery EasyUi DataGrid 服务器端分页,添加增加,修改,删除 按钮
来源:互联网 发布:淘宝上传图片尺寸大小 编辑:程序博客网 时间:2024/05/01 17:55
Html代码
<body class="easyui-layout">
<form id="form1" runat="server">
<div data-options="region:'north',split:true" style="height: 20px; padding: 10px;
background-color: #F4F4F4; overflow: hidden;">
<label id="labcompany">公司名称</label>
<input type="text" id="compname" class="easyui-validatebox" />
<a href="#" class="easyui-linkbutton" onclick="serachfun()">查询</a>
</div>
<div data-options="region:'center',split:false" style="height: auto; padding: 27px;
padding-left: 0; overflow: hidden;">
<table id="ReceiveList">
</table>
</div>
</form>
</body>
<form id="form1" runat="server">
<div data-options="region:'north',split:true" style="height: 20px; padding: 10px;
background-color: #F4F4F4; overflow: hidden;">
<label id="labcompany">公司名称</label>
<input type="text" id="compname" class="easyui-validatebox" />
<a href="#" class="easyui-linkbutton" onclick="serachfun()">查询</a>
</div>
<div data-options="region:'center',split:false" style="height: auto; padding: 27px;
padding-left: 0; overflow: hidden;">
<table id="ReceiveList">
</table>
</div>
</form>
</body>
js代码
<script type="text/javascript" language="javascript">
$(function () {
$('#ReceiveList').datagrid({
// width: 700,
// height: 350,
rownumbers: true,
singleSelect: true,
pagination: true,
pageSize: 2,
pageList: [1, 2, 5],
title: '收件箱',
loadMsg: "正在加载,请稍等...",
autoRowHeight: false,
striped: true,
collapsible: true,
fit: true,
fitColumns: false,
url: 'DealData.ashx?r=' +Math.random,
method: 'get',
queryParams: { "action": "query","compname": $.trim($('#compname').val()) },
$(function () {
$('#ReceiveList').datagrid({
// width: 700,
// height: 350,
rownumbers: true,
singleSelect: true,
pagination: true,
pageSize: 2,
pageList: [1, 2, 5],
title: '收件箱',
loadMsg: "正在加载,请稍等...",
autoRowHeight: false,
striped: true,
collapsible: true,
fit: true,
fitColumns: false,
url: 'DealData.ashx?r=' +Math.random,
method: 'get',
queryParams: { "action": "query","compname": $.trim($('#compname').val()) },
columns: [[
{field: 'CompName', title: '公司名称' },
{ field: 'mailNum', title: '信箱号' },
{ field: 'ShowName', title: '显示方式' },
{ field: 'opt', title: '操作', formatter: formatData }
]]
});
//设置分页控件
var p = $('#ReceiveList').datagrid('getPager');
$(p).pagination({
beforePageText: '第',
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录'
});
});
{field: 'CompName', title: '公司名称' },
{ field: 'mailNum', title: '信箱号' },
{ field: 'ShowName', title: '显示方式' },
{ field: 'opt', title: '操作', formatter: formatData }
]]
});
//设置分页控件
var p = $('#ReceiveList').datagrid('getPager');
$(p).pagination({
beforePageText: '第',
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录'
});
});
//查询后重新设置url
function serachfun() {
var copmname = $.trim($('#compname').val());
$('#ReceiveList').datagrid({
url: 'DealData.ashx?r=' +Math.random,
method: 'get',
queryParams: { "action": "query","compname": $.trim($('#compname').val()) }, });
// alert('ok');
}
function serachfun() {
var copmname = $.trim($('#compname').val());
$('#ReceiveList').datagrid({
url: 'DealData.ashx?r=' +Math.random,
method: 'get',
queryParams: { "action": "query","compname": $.trim($('#compname').val()) }, });
// alert('ok');
}
//每一行添加查看、编辑、删除按钮
function formatData (value, row, index) {
var s = '<a href="#" onclick="view(\'' + row.CompName + '\')">查看</a> ';
var e = '<a href="#" onclick="edit(\'' + row.CompName + '\')">编辑</a> ';
var d = '<a href="#" onclick="del(\'' + row.CompName + '\')">删除</a> ';
return s + e + d;
// var str = '<a href="#" class="easyui-linkbutton" onclick="serach(\'' + row.CompName + '\')">明细</a>';
// return str;
}
function view(compname) {
alert('查看');
}
function edit(compname) {
alert('编辑');
}
function del(compname) {
alert('删除');
}
</script>
function formatData (value, row, index) {
var s = '<a href="#" onclick="view(\'' + row.CompName + '\')">查看</a> ';
var e = '<a href="#" onclick="edit(\'' + row.CompName + '\')">编辑</a> ';
var d = '<a href="#" onclick="del(\'' + row.CompName + '\')">删除</a> ';
return s + e + d;
// var str = '<a href="#" class="easyui-linkbutton" onclick="serach(\'' + row.CompName + '\')">明细</a>';
// return str;
}
function view(compname) {
alert('查看');
}
function edit(compname) {
alert('编辑');
}
function del(compname) {
alert('删除');
}
</script>
后台代码
DealData.ashx
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
int intPageSize = int.Parse(context.Request["rows"].ToString());
int intCurrentPage = int.Parse(context.Request["page"].ToString());
string strJson = "";
if (context.Request["action"] == "query")
{
string compname = context.Request["compname"].ToString();
int totalSize;
DataTable dt = new AdvertInfoManager().getPartAdvert(compname, intPageSize, intCurrentPage, out totalSize);
strJson = DataTableJson(dt, totalSize);
}
context.Response.Write(strJson);
}
{
context.Response.ContentType = "text/plain";
int intPageSize = int.Parse(context.Request["rows"].ToString());
int intCurrentPage = int.Parse(context.Request["page"].ToString());
string strJson = "";
if (context.Request["action"] == "query")
{
string compname = context.Request["compname"].ToString();
int totalSize;
DataTable dt = new AdvertInfoManager().getPartAdvert(compname, intPageSize, intCurrentPage, out totalSize);
strJson = DataTableJson(dt, totalSize);
}
context.Response.Write(strJson);
}
//返回json
public static string DataTableJson(DataTable dt, int totalSize)
{
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.Append("{");
jsonBuilder.Append("\"total\":" + totalSize);
jsonBuilder.Append(",");
jsonBuilder.Append("\"rows\":[");
for (int i = 0; i < dt.Rows.Count; i++)
{
jsonBuilder.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
jsonBuilder.Append("\"");
jsonBuilder.Append(dt.Columns[j].ColumnName);
jsonBuilder.Append("\":\"");
jsonBuilder.Append(dt.Rows[i][j].ToString());
jsonBuilder.Append("\",");
}
jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("},");
} jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("]");
jsonBuilder.Append("}");
return jsonBuilder.ToString();
}
public static string DataTableJson(DataTable dt, int totalSize)
{
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.Append("{");
jsonBuilder.Append("\"total\":" + totalSize);
jsonBuilder.Append(",");
jsonBuilder.Append("\"rows\":[");
for (int i = 0; i < dt.Rows.Count; i++)
{
jsonBuilder.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
jsonBuilder.Append("\"");
jsonBuilder.Append(dt.Columns[j].ColumnName);
jsonBuilder.Append("\":\"");
jsonBuilder.Append(dt.Rows[i][j].ToString());
jsonBuilder.Append("\",");
}
jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("},");
} jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
jsonBuilder.Append("]");
jsonBuilder.Append("}");
return jsonBuilder.ToString();
}
//数据库查询
public DataTable getPartAdvert(string compname,int intPageSize, int intCurrentPage, out int totalSize)
{
string sql = @"select RowNumber,CompName,ShowName,mailNum from ( SELECT ROW_NUMBER() OVER (ORDER BY CompName) AS RowNumber,CompName ,ShowName,b.mailNum FROM T_AdvertInfo a,T_MailToAdvert b,LedShowStyle c, LedFontStyle d,ColorStyle e where a.AdvGUID=b.AdvGUID and c.showstyle=a.showstyle and d.showFont=a.showFont and e.showColor=a.showColor) A where RowNumber>=" + (intPageSize * (intCurrentPage - 1) + 1) + " and RowNumber<=" + intPageSize * intCurrentPage;
string sql2 = "select count(*) from T_AdvertInfo where 1=1 ";
if (compname!="")
{
sql += " and CompName like '%"+compname+"%'";
sql2 += " and CompName like '%" + compname + "%'";
}
totalSize = Convert.ToInt32(DBHelper.getData(sql2).Rows[0][0].ToString());
return DBHelper.getData(sql);
}
{
string sql = @"select RowNumber,CompName,ShowName,mailNum from ( SELECT ROW_NUMBER() OVER (ORDER BY CompName) AS RowNumber,CompName ,ShowName,b.mailNum FROM T_AdvertInfo a,T_MailToAdvert b,LedShowStyle c, LedFontStyle d,ColorStyle e where a.AdvGUID=b.AdvGUID and c.showstyle=a.showstyle and d.showFont=a.showFont and e.showColor=a.showColor) A where RowNumber>=" + (intPageSize * (intCurrentPage - 1) + 1) + " and RowNumber<=" + intPageSize * intCurrentPage;
string sql2 = "select count(*) from T_AdvertInfo where 1=1 ";
if (compname!="")
{
sql += " and CompName like '%"+compname+"%'";
sql2 += " and CompName like '%" + compname + "%'";
}
totalSize = Convert.ToInt32(DBHelper.getData(sql2).Rows[0][0].ToString());
return DBHelper.getData(sql);
}
- asp.net与JQuery EasyUi DataGrid 服务器端分页,添加增加,修改,删除 按钮
- jquery easyui datagrid的增加,修改,删除
- jQuery EasyUI DataGrid 分页 FOR ASP.NET
- jquery-easyui datagrid 中每行增加删除按钮成功删除
- jquery easyui datagrid添加前台分页
- Jquery EasyUI dataGrid 修改默认分页大小
- easyui datagrid 弹窗添加修改删除
- jquery easyui实现datagrid表格向数据库中进行增加,修改和删除操作
- Jquery easyui DataGrid分页
- jquery easyui datagrid 分页
- easyui中获取datagrid分页控件并添加操作按钮
- asp 数据库 操作 增加 删除 修改 分页
- Jquery easyui 的datagrid 每行增加操作链接-修改
- EasyUI DataGrid 窗体中的修改和删除按钮
- Jquery EasyUI的添加,修改,删除,查询
- 基于asp.net + easyui框架,一步步学习easyui-datagrid——实现添加、编辑、删除(三)
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
- UITabBarController
- MOS管击穿原因和防护措施!
- android系统移植emmc记录(总)
- 为Windows Azure的虚机配置负载均衡
- I cannot mount JFFS2 and see "Magic bitmask 0x1985 not found" messages
- asp.net与JQuery EasyUi DataGrid 服务器端分页,添加增加,修改,删除 按钮
- JAVABAT実行手順
- Print the rman output
- Linux 磁盘配额
- SQL Server 中的group by, rollup 和 grouping关键字的用法
- iOS通过http post上传图片
- android 获取sim卡运营商信息(转)
- 算法导论答案 16.2-2 0-1背包问题的动态规划算法
- The backup progress monitor