AJAX_利用 Linq+Jquery+Ajax 实现异步分页功能可简化带宽压力,在Web显示的时候我们经常会遇
where !string.IsNullOrEmpty(p.出库确认人) && p.出库日期 != null
text-align: center;
badpageindex = parseInt(thisindex) - 1;
(lstGetBadProductData.Count() / 20 + 1));
border-left-color: #e6e7e1;
}
var _go = $("#txtGoPage").val();
{
pageSize * (int.Parse(context.Request["currPage"]) - 1)).Take(pageSize)
$(".pages").click(function () {
+ "_" + $("#txtPinfan").val() + "_" +
var page = returnData.split('_')[1].split(',');
border-right-color: #09c;
效果图:
badpageindex = parseInt(thisindex) + 1;
<a>尾页</a>
if (!string.IsNullOrEmpty(context.Request["BadProductWhere"]) &&
}
$("#txtGoPage").val("");
.pages a {
+ "_" + $("#txtPinfan").val() + "_" +
border-right-color: #e6e7e1;
padding-top: 0px;
return;
{
<span>
/*分页*/
<a>下页</a>
#endregion
设置它们的Class = "page" 以便于给它们增加Click事件操作分页
<th>仓库确认</th>
//检索条件
var cssName = rowCount % 2 == 0 ? "warning" : "error";
var search = $("#txtFactroy").val() + "_" + $("#txtTimeSelect").val()
#region // B品标题信息
页
}
JS代码:
return;
sbBadProductInfo.Append(@"<td>" + item.出库确认人 + "</td>");
}
<th>箱单编号</th>
success: function (returnData, textstatus, xmlhttprequest)
BadPageIndex(max, search);
</div>");
margin: 0 auto;
data: "BadProductWhere=" + encodeURIComponent(search) + "&currPage=1",
</thead><tbody>");
sbBadProductInfo.Append(@"<div>
}
case 'next':
case 'first':
var type = $(this).attr("id");
$("#txtGoPage").val("");
border-bottom-color: #09c;
Html代码:
</div>
padding-right: 6px;
sbBadProductInfo.Append(@"<td>" + item.箱单编号 + "</td>");
</span>
用下面的div输出返回的结果
height: 30px;
引入: <script src="https://www.xp.cn/assets/js/jquery-1.8.2.min.js"></script>//可以为其他版本
sbBadProductInfo.Append(@"<div>
//分页操作动作
case 'last':
});
sbBadProductInfo.Append(@"<td>" + item.装箱生成日期 + "</td>");
<th>查看明细</th>
var page = returnData.split('_')[1].split(',');
rowCount++;
padding-bottom: 0px;
sbBadProductInfo.Append(@"<tr>");
//取得控件类型是ID还是class
{
sbBadProductInfo.Append(@"<td>" + item.装箱箱号 + "</td>");
<th>装箱品番</th>
}
url: "ResponseHandler.ashx"//回传到一般处理程序中处理//回传参数表示请求的是第几页,encodeURIComponent 格式化中文以防乱码
badpageindex = max;
overflow: hidden;
sbBadProductInfo.Append(@"<td>" + item.装箱件数 + "</td>");
border-top-color: #09c;
</div>
$(document).ready(function ()
return;
cursor: pointer;
$("#PageCount").text(page[3]);//共多少页 }
$("#Index").text(page[2]);
BadPageIndex(badpageindex, search);
$("#Index").text(page[2]);//当前页
.pages {
}
border-bottom-color: #09c;
$("#ItemCount").text(page[1]);
border-left: 1px solid;
function BadPageIndex(index, searchwhere) {
var badpageindex;
badpageindex = 1;
}
$("#PageCount").text(page[3]);
BadPageIndex(_go, search);
</div>
</div>
<tr>
<a>上页</a>
<th>装箱生成日期</th>
!string.IsNullOrEmpty(context.Request["currPage"]))
margin-right: 2px;
"," + (lstGetBadProductData.Count() % 20 == 0 ? (lstGetBadProductData.Count() / 20) :
border-top: 1px solid;
datatype: "json",//把返回来的数据 json
else
/// </summary>
text-decoration: none;
},
<i></i>B品箱单信息
<div>
data: "BadProductWhere=" + encodeURIComponent(searchwhere) + "&currPage=" + index,
{
context.Response.End();
$("#divDisplay").css('display', 'none');
}
private int pageSize = 20;
context.Response.Write(sbBadProductInfo.ToString() + "_" + pageInfo);
}
<div>
error: function () {
List<bstate_view> lstGetBadItemData = (lstGetBadProductData.Count > pageSize ?
border-left-color: #09c;
border-right: 1px solid;
/// <summary>
sbBadProductInfo.Append(@"/></td></tr>");
padding-left: 6px;
//取得当前是多少页
</div>");
});
case 'prev':
font-family: verdana, helvetica, arial, sans-serif;
{
async: false,//禁止使用浏览器缓存
复制代码 代码如下:
border-bottom-color: #e6e7e1;lstGetBadProductData.Skip(int.Parse(context.Request["currPage"]) == 1 ? 0 :
<th>工厂名称</th>
sbBadProductInfo.Append(@"<td>" + item.仓库确认 + "</td>");
{
type: "post",
<div><div>
$('input[type="checkbox"][name="option1"]:checked').val();
style='width: 80px; height: 30px;' value='查看明细'");
当前<span></span>/<span></span>页
$("#showPage").css('display', 'block');
$("#SumCount").text(page[0]);//共多少条数据
$("#txtGoPage").val("");
.pages a:hover {
}
$("#txtGoPage").val("");
<a>首页</a>
//清除转向页面
sbBadProductInfo.Append(@"</tbody></table>
padding-top: 2px;
$("#divBadProductInfo").html(returnData.split('_')[0]);
BadPageIndex(1, search);//Ajax 回传函数
复制代码 代码如下:
<thead>sbBadProductInfo.Append(@"<td><input type='button'
<th>出库确认人</th>
return;
padding-bottom: 2px;
type: "post",<span>//回传格式
border-left-color: #09c;
$.ajax({
border-top-color: #e6e7e1;
C# 代码:(ResponseHandler.ashx)
//总页数大于1的情况下上下首末页可用
<th>出库日期</th>
}
border-right-color: #09c;
复制代码 代码如下:
badpageindex = _go;datatype: "json",
sbBadProductInfo.Append(@"<td>" + item.工厂名称 + "</td>");
#endregion
return;
共<span></span> 条数据,每页<span></span> 条,
</div>
StringBuilder sbBadProductInfo = new StringBuilder();
url: "ResponseHandler.ashx",
$('input[type="checkbox"][name="option1"]:checked').val();
case 'go':
<div>
foreach (var item in lstGetBadItemData)
if (badpageindex > parseInt($("#PageCount").html())) return;
var max = parseInt($("#PageCount").html());
if (parseFloat($("#PageCount").html()) > 1) {
success: function (returnData, textstatus, xmlhttprequest) {
{
<table>
color: #09c;
}
$("#divBadProductInfo").html(returnData.split('_')[0]);//返回值分割显示
sbBadProductInfo.Append(@"<td>" + item.装箱品番 + "</td>");
</div>
border-bottom: 1px solid;
$("#SumCount").text(page[0]);
<div>
</tr>
Css代码:
//BadProductWhere 查询条件
.pages a {
line-height: 20px;
$("#ItemCount").text(page[1]);//每页多少条数据
});
$("#txtGoPage").val("");
}
{
BadPageIndex(badpageindex, search);
<th>装箱箱号</th>
: lstGetBadProductData).ToList<bstate_view>();
#region ==>B品箱单信息
string pageInfo = lstGetBadProductData.Count() + "," + pageSize + "," + context.Request["currPage"] +
</div>
{
if (badpageindex < 1) return;
在Web显示的时候我们经常会遇到分页显示,而网上的分页方法甚多,但都太过于消耗带宽,所以我想到了用Ajax来分页,利用返回的Json来处理返回的数据,大大简化了带宽的压力。先说下思路,无非就是异步执行ajax 把新列表所需要的数据用json格式返回来,输出table,你可以输出ui li(输出效率高) 在页面上。
sbBadProductInfo.Append(@"<td>" + item.出库日期 + "</td>");
复制代码 代码如下:
$.ajax({<div></div>
background-color: #fff;
跳转到第<input type="text" />
</div>
async: false,
}
List<bstate_view> lstGetBadProductData = (from p in lstGetBadProductData
复制代码 代码如下:
alert("服务错误");$("#showPage").css('display', 'block');//显示分页
border-top-color: #09c;
switch (type) {
</div>
<th>装箱件数</th>
})
<div>
.pages a.next {
var thisindex = $("#Index").text();
<input type="button" value="跳转" />
//index,页面索引例如1,2,3
var search = $("#txtFactroy").val() + "_" + $("#txtTimeSelect").val()
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jq/ui/5652.shtml
