<div class="pagination" id="divPager"></div>
<div style=" display:none;">
<label id="lblTotalRecord">50</label>// taoplam kayıt sayısı
<label id="lblRecordSize">15 </label>// sayfada kaç adet
<label id="lblNumSize">10 </label>// numarator sayısı
<label id="lblCurrentPage">2 </label>// geçerli sayfa
</div>
<script type="text/javascript">
$(document).ready(function () {
f_GetPage("/AHome/Hizmet/Sayfa/");
});
$(document).ready(function () {
f_GetPage("/AHome/Hizmet/Sayfa/");
});
function
f_GetPage (path) {
var TotalRecord, RecordSize, NumSize, CurrentPage;
TotalRecord = jQuery("#lblTotalRecord").text(); RecordSize = jQuery("#lblRecordSize").text(); NumSize = jQuery("#lblNumSize").text(); CurrentPage = jQuery("#lblCurrentPage").text();
jQuery("#divPager > ul ").html(f_Page(path, TotalRecord, RecordSize, NumSize, CurrentPage));
}
function f_Page(Path, TotalRecord, RecordSize, NumSize, CurrentPage) {
var sb = "0";
TotalRecord = parseInt(TotalRecord);RecordSize = parseInt(RecordSize);CurrentPage = parseInt(CurrentPage);
if (TotalRecord > RecordSize) {
sb = "<span class='spnc' id='spnc" + NumSize + "'></span>";
var TotalNum;
TotalNum = TotalRecord % RecordSize ? Math.floor(TotalRecord / RecordSize + 1) : TotalRecord / RecordSize;
if (TotalNum >= CurrentPage) {
var startindex = CurrentPage % NumSize ? Math.floor(CurrentPage / NumSize) : CurrentPage / NumSize - 1;
startindex = startindex * NumSize;
var finishindex = parseInt(startindex) + parseInt(NumSize);
var tfi = TotalRecord % RecordSize ? Math.floor(TotalRecord / RecordSize) + 1 : TotalRecord / RecordSize;
if (finishindex > tfi) finishindex = tfi;
if (startindex >= NumSize) sb += "<li><a href=" + startindex + "> Önceki </a></li>"; else sb += "<li><a href='#'> Önceki </a></li>";
for (var i = startindex + 1; i <= finishindex; i++) {
if (i == CurrentPage) sb += "<li class='active'><a href='#'>" + i + "</a></li>";
else sb += "<li><a href='" + Path + i + "'>" + i + "</a><li>";
}
var r = CurrentPage % NumSize ? (parseInt(Math.floor(CurrentPage / NumSize)) * NumSize + parseInt(NumSize)) : ((parseInt(CurrentPage / NumSize) - 1) * NumSize + parseInt(NumSize));
if (r < TotalNum) sb += "<li><a href='" + i + "'> :right</a></li>"; else sb += "<li><a href='#'>Sonraki</a></li>"
}
}
return sb;
}
</script>
Hiç yorum yok:
Yorum Gönder