利用 Linq+Jquery+Ajax 实现异步分页功能可简化带宽(2)


var badpageindex;
//index,页面索引例如1,2,3
//BadProductWhere 查询条件
function BadPageIndex(index, searchwhere) {
$.ajax({
type: "post",
url: "ResponseHandler.ashx",
data: "BadProductWhere=" + encodeURIComponent(searchwhere) + "&currPage=" + index,
datatype: "json",
async: false,
success: function (returnData, textstatus, xmlhttprequest) {
$("#divDisplay").css('display', 'none');
$("#showPage").css('display', 'block');
$("#divBadProductInfo").html(returnData.split('_')[0]);
var page = returnData.split('_')[1].split(',');
$("#SumCount").text(page[0]);
$("#ItemCount").text(page[1]);
$("#Index").text(page[2]);
$("#PageCount").text(page[3]);
},
error: function () {
alert("服务错误");
}
});

}


C# 代码:(ResponseHandler.ashx)

复制代码 代码如下:


/// <summary>
/// 每页显示条数
/// </summary>
private int pageSize = 20;
StringBuilder sbBadProductInfo = new StringBuilder();
if (!string.IsNullOrEmpty(context.Request["BadProductWhere"]) &&
!string.IsNullOrEmpty(context.Request["currPage"]))
{
#region // B品标题信息
sbBadProductInfo.Append(@"<div>
<div><div>
<span>
<i></i>B品箱单信息
</span>
</div>");
sbBadProductInfo.Append(@"<div>
<div>
<div>
<table>
<thead>
<tr>
<th>箱单编号</th>
<th>装箱生成日期</th>
<th>工厂名称</th>
<th>装箱品番</th>
<th>装箱箱号</th>
<th>装箱件数</th>
<th>仓库确认</th>
<th>出库确认人</th>
<th>出库日期</th>
<th>查看明细</th>
</tr>
</thead><tbody>");
#endregion
List<bstate_view> lstGetBadProductData = (from p in lstGetBadProductData
where !string.IsNullOrEmpty(p.出库确认人) && p.出库日期 != null
select p).ToList<bstate_view>();
string pageInfo = lstGetBadProductData.Count() + "," + pageSize + "," + context.Request["currPage"] +
"," + (lstGetBadProductData.Count() % 20 == 0 ? (lstGetBadProductData.Count() / 20) :
(lstGetBadProductData.Count() / 20 + 1));
List<bstate_view> lstGetBadItemData = (lstGetBadProductData.Count > pageSize ?
lstGetBadProductData.Skip(int.Parse(context.Request["currPage"]) == 1 ? 0 :
pageSize * (int.Parse(context.Request["currPage"]) - 1)).Take(pageSize)
: lstGetBadProductData).ToList<bstate_view>();
#region ==>B品箱单信息
foreach (var item in lstGetBadItemData)
{
var cssName = rowCount % 2 == 0 ? "warning" : "error";
sbBadProductInfo.Append(@"<tr>");
sbBadProductInfo.Append(@"<td>" + item.箱单编号 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.装箱生成日期 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.工厂名称 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.装箱品番 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.装箱箱号 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.装箱件数 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.仓库确认 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.出库确认人 + "</td>");
sbBadProductInfo.Append(@"<td>" + item.出库日期 + "</td>");
sbBadProductInfo.Append(@"<td><input type='button'
style='width: 80px; height: 30px;' value='查看明细'");
sbBadProductInfo.Append(@"/></td></tr>");
rowCount++;
}
sbBadProductInfo.Append(@"</tbody></table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>");
#endregion

context.Response.Write(sbBadProductInfo.ToString() + "_" + pageInfo);
context.Response.End();


分页效果:

利用 Linq+Jquery+Ajax 实现异步分页功能可简化带宽


利用 Linq+Jquery+Ajax 实现异步分页功能可简化带宽


利用 Linq+Jquery+Ajax 实现异步分页功能可简化带宽

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfwwgj.html