婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > 利用 Linq+Jquery+Ajax 實(shí)現(xiàn)異步分頁(yè)功能可簡(jiǎn)化帶寬壓力

利用 Linq+Jquery+Ajax 實(shí)現(xiàn)異步分頁(yè)功能可簡(jiǎn)化帶寬壓力

熱門標(biāo)簽:上海浦東百度地圖標(biāo)注中心注冊(cè) 徐州電銷卡外呼系統(tǒng)供應(yīng)商 百靈鳥 目標(biāo)三維地圖標(biāo)注 科智聯(lián)智能電銷機(jī)器人 外呼系統(tǒng)獲取客戶手機(jī)號(hào) 襄陽(yáng)外呼系統(tǒng)接口 青海醫(yī)療智能外呼系統(tǒng)怎么樣 老虎郵局地圖標(biāo)注點(diǎn)
在Web顯示的時(shí)候我們經(jīng)常會(huì)遇到分頁(yè)顯示,而網(wǎng)上的分頁(yè)方法甚多,但都太過(guò)于消耗帶寬,所以我想到了用Ajax來(lái)分頁(yè),利用返回的Json來(lái)處理返回的數(shù)據(jù),大大簡(jiǎn)化了帶寬的壓力。先說(shuō)下思路,無(wú)非就是異步執(zhí)行ajax 把新列表所需要的數(shù)據(jù)用json格式返回來(lái),輸出table,你可以輸出ui li(輸出效率高) 在頁(yè)面上。

效果圖:
 
Html代碼:
復(fù)制代碼 代碼如下:

設(shè)置它們的Class = "page" 以便于給它們?cè)黾覥lick事件操作分頁(yè)
div id="showPage" style="width: 650px; margin: 0 auto; display: none" class="pages">
div style="float: left">
a id="first" class="pages">首頁(yè)/a>
a id="prev" class="pages">上頁(yè)/a>
a id="next" class="pages">下頁(yè)/a>
a id="last" class="pages">尾頁(yè)/a>
跳轉(zhuǎn)到第input type="text" id="txtGoPage" style="width: 45px; height: 15px; border: 1px solid" />
頁(yè)
/div>
div style="margin: 0; float: left">
input type="button" class="pages btn btn-info" id="go" value="跳轉(zhuǎn)" />
共span id="SumCount">/span> 條數(shù)據(jù),每頁(yè)span id="ItemCount">/span> 條,
當(dāng)前span id="Index">/span>/span id="PageCount">/span>頁(yè)
/div>
/div>
用下面的div輸出返回的結(jié)果
div id="divBadProductInfo">/div>

Css代碼:
復(fù)制代碼 代碼如下:

/*分頁(yè)*/
.pages {
cursor: pointer;
text-align: center;
margin: 0 auto;
padding-right: 0px;
padding-bottom: 2px;
padding-top: 2px;
font-family: verdana, helvetica, arial, sans-serif;
}

.pages a {
border-right: 1px solid;
padding-right: 6px;
border-top: 1px solid;
padding-left: 6px;
padding-bottom: 0px;
overflow: hidden;
border-left: 1px solid;
line-height: 20px;
margin-right: 2px;
padding-top: 0px;
border-bottom: 1px solid;
height: 30px;
}

.pages a {
border-left-color: #e6e7e1;
border-bottom-color: #e6e7e1;
color: #09c;
border-top-color: #e6e7e1;
background-color: #fff;
border-right-color: #e6e7e1;
}

.pages a:hover {
text-decoration: none;
border-left-color: #09c;
border-bottom-color: #09c;
border-top-color: #09c;
border-right-color: #09c;
}

.pages a.next {
border-left-color: #09c;
border-bottom-color: #09c;
border-top-color: #09c;
border-right-color: #09c;
}

JS代碼:

引入: script src="assets/js/jquery-1.8.2.min.js">/script>//可以為其他版本
復(fù)制代碼 代碼如下:

$(document).ready(function ()
{
//檢索條件
var search = $("#txtFactroy").val() + "_" + $("#txtTimeSelect").val()
+ "_" + $("#txtPinfan").val() + "_" +
$('input[type="checkbox"][name="option1"]:checked').val();
$.ajax({
type: "post",span style="color:#ff0000;">//回傳格式
url: "ResponseHandler.ashx"http://回傳到一般處理程序中處理//回傳參數(shù)表示請(qǐng)求的是第幾頁(yè),encodeURIComponent 格式化中文以防亂碼
data: "BadProductWhere=" + encodeURIComponent(search) + "currPage=1",
datatype: "json",//把返回來(lái)的數(shù)據(jù) json
async: false,//禁止使用瀏覽器緩存
success: function (returnData, textstatus, xmlhttprequest)
{
$("#showPage").css('display', 'block');//顯示分頁(yè)
$("#divBadProductInfo").html(returnData.split('_')[0]);//返回值分割顯示
var page = returnData.split('_')[1].split(',');
$("#SumCount").text(page[0]);//共多少條數(shù)據(jù)
$("#ItemCount").text(page[1]);//每頁(yè)多少條數(shù)據(jù)
$("#Index").text(page[2]);//當(dāng)前頁(yè)
$("#PageCount").text(page[3]);//共多少頁(yè) }
});
//清除轉(zhuǎn)向頁(yè)面
$("#txtGoPage").val("");

//分頁(yè)操作動(dòng)作
$(".pages").click(function () {
//總頁(yè)數(shù)大于1的情況下上下首末頁(yè)可用
if (parseFloat($("#PageCount").html()) > 1) {
//取得控件類型是ID還是class
var type = $(this).attr("id");
//取得當(dāng)前是多少頁(yè)
var thisindex = $("#Index").text();
var search = $("#txtFactroy").val() + "_" + $("#txtTimeSelect").val()
+ "_" + $("#txtPinfan").val() + "_" +
$('input[type="checkbox"][name="option1"]:checked').val();
switch (type) {
case 'first':
{
$("#txtGoPage").val("");
badpageindex = 1;
BadPageIndex(1, search);//Ajax 回傳函數(shù)
return;
}
case 'prev':
{
$("#txtGoPage").val("");
badpageindex = parseInt(thisindex) - 1;
if (badpageindex 1) return;
BadPageIndex(badpageindex, search);
return;
}
case 'next':
{
$("#txtGoPage").val("");
badpageindex = parseInt(thisindex) + 1;
if (badpageindex > parseInt($("#PageCount").html())) return;
else
BadPageIndex(badpageindex, search);
return;
}
case 'last':
{
var max = parseInt($("#PageCount").html());
$("#txtGoPage").val("");
badpageindex = max;
BadPageIndex(max, search);
return;
}
case 'go':
{
var _go = $("#txtGoPage").val();
badpageindex = _go;
BadPageIndex(_go, search);
return;
}
}
}
})
});

復(fù)制代碼 代碼如下:

var badpageindex;
//index,頁(yè)面索引例如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("服務(wù)錯(cuò)誤");
}
});

}

C# 代碼:(ResponseHandler.ashx)
復(fù)制代碼 代碼如下:

/// summary>
/// 每頁(yè)顯示條數(shù)
/// /summary>
private int pageSize = 20;
StringBuilder sbBadProductInfo = new StringBuilder();
if (!string.IsNullOrEmpty(context.Request["BadProductWhere"])
!string.IsNullOrEmpty(context.Request["currPage"]))
{
#region // B品標(biāo)題信息
sbBadProductInfo.Append(@"div class='row-fluid'>
div class='span12 widget'>div class='widget-header'>
span class='title'>
i class='icol-blog'>/i>B品箱單信息
/span>
/div>");
sbBadProductInfo.Append(@"div class='widget-content summary-list'>
div class='row-fluid' style='padding-top: 2px;'>
div class='span12 section'>
table class='table table-bordered table-striped'>
thead>
tr>
th>箱單編號(hào)/th>
th>裝箱生成日期/th>
th>工廠名稱/th>
th>裝箱品番/th>
th>裝箱箱號(hào)/th>
th>裝箱件數(shù)/th>
th>倉(cāng)庫(kù)確認(rèn)/th>
th>出庫(kù)確認(rèn)人/th>
th>出庫(kù)日期/th>
th>查看明細(xì)/th>
/tr>
/thead>tbody>");
#endregion
Listbstate_view> lstGetBadProductData = (from p in lstGetBadProductData
where !string.IsNullOrEmpty(p.出庫(kù)確認(rèn)人) p.出庫(kù)日期 != null
select p).ToListbstate_view>();
string pageInfo = lstGetBadProductData.Count() + "," + pageSize + "," + context.Request["currPage"] +
"," + (lstGetBadProductData.Count() % 20 == 0 ? (lstGetBadProductData.Count() / 20) :
(lstGetBadProductData.Count() / 20 + 1));
Listbstate_view> lstGetBadItemData = (lstGetBadProductData.Count > pageSize ?
lstGetBadProductData.Skip(int.Parse(context.Request["currPage"]) == 1 ? 0 :
pageSize * (int.Parse(context.Request["currPage"]) - 1)).Take(pageSize)
: lstGetBadProductData).ToListbstate_view>();
#region ==>B品箱單信息
foreach (var item in lstGetBadItemData)
{
var cssName = rowCount % 2 == 0 ? "warning" : "error";
sbBadProductInfo.Append(@"tr class='" + cssName + "'>");
sbBadProductInfo.Append(@"td>" + item.箱單編號(hào) + "/td>");
sbBadProductInfo.Append(@"td>" + item.裝箱生成日期 + "/td>");
sbBadProductInfo.Append(@"td>" + item.工廠名稱 + "/td>");
sbBadProductInfo.Append(@"td>" + item.裝箱品番 + "/td>");
sbBadProductInfo.Append(@"td>" + item.裝箱箱號(hào) + "/td>");
sbBadProductInfo.Append(@"td>" + item.裝箱件數(shù) + "/td>");
sbBadProductInfo.Append(@"td>" + item.倉(cāng)庫(kù)確認(rèn) + "/td>");
sbBadProductInfo.Append(@"td>" + item.出庫(kù)確認(rèn)人 + "/td>");
sbBadProductInfo.Append(@"td>" + item.出庫(kù)日期 + "/td>");
sbBadProductInfo.Append(@"td>input type='button' class='btn btn-primary'
style='width: 80px; height: 30px;' value='查看明細(xì)'");
sbBadProductInfo.Append(@" onclick='OpenBadInfo(" + item.箱編號(hào) + ");'/>/td>/tr>");
rowCount++;
}
sbBadProductInfo.Append(@"/tbody>/table>
/div>
/div>
/div>
/div>
/div>
/div>
/div>");
#endregion

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

分頁(yè)效果:


您可能感興趣的文章:
  • jquery 插件 web2.0分格的分頁(yè)腳本,可用于ajax無(wú)刷新分頁(yè)
  • 分享精心挑選的12款優(yōu)秀jQuery Ajax分頁(yè)插件和教程
  • jQuery Pagination Ajax分頁(yè)插件(分頁(yè)切換時(shí)無(wú)刷新與延遲)中文翻譯版
  • jquery+css3打造一款ajax分頁(yè)插件(自寫)
  • jquery插件pagination實(shí)現(xiàn)無(wú)刷新ajax分頁(yè)
  • PHP+jQuery+Ajax實(shí)現(xiàn)分頁(yè)效果 jPaginate插件的應(yīng)用
  • 使用Jquery+Ajax+Json如何實(shí)現(xiàn)分頁(yè)顯示附JAVA+JQuery實(shí)現(xiàn)異步分頁(yè)
  • jQuery ajax分頁(yè)插件實(shí)例代碼
  • MVC+jQuery.Ajax異步實(shí)現(xiàn)增刪改查和分頁(yè)
  • laypage前端分頁(yè)插件實(shí)現(xiàn)ajax異步分頁(yè)

標(biāo)簽:佛山 商洛 咸寧 辛集 股票 荊州 紅河 揭陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《利用 Linq+Jquery+Ajax 實(shí)現(xiàn)異步分頁(yè)功能可簡(jiǎn)化帶寬壓力》,本文關(guān)鍵詞  利用,Linq+Jquery+Ajax,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《利用 Linq+Jquery+Ajax 實(shí)現(xiàn)異步分頁(yè)功能可簡(jiǎn)化帶寬壓力》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于利用 Linq+Jquery+Ajax 實(shí)現(xiàn)異步分頁(yè)功能可簡(jiǎn)化帶寬壓力的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 南投县| 顺义区| 得荣县| 岐山县| 邯郸县| 临颍县| 麻栗坡县| 长岭县| 昭觉县| 汉沽区| 黄龙县| 临高县| 开鲁县| 岚皋县| 南京市| 廊坊市| 如皋市| 康乐县| 汝州市| 公安县| 哈巴河县| 元阳县| 巩留县| 虹口区| 五原县| 金昌市| 怀安县| 易门县| 稻城县| 乾安县| 伊金霍洛旗| 铜川市| 广州市| 盐池县| 郴州市| 本溪市| 马龙县| 钟山县| 江华| 温泉县| 奎屯市|