<span style="font-size:18px;">//分页控件
$(document).ready(function () {
var pageSize = 10;
var index;
//分页控件
$.jqPaginator('#pagination2', {
pageSize: pageSize,
totalCounts: 10, //总条数
visiblePages: 10,
currentPage: 1,
prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
next: '<li class="next"><a href="javascript:;">下一页</a></li>',
page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
onPageChange: function (num, type) {
index = num;
getData();
}
});
function getData() {
$.post("@Url.Action("SelectBookStudent")", {
"pageSize": pageSize,
"pageIndex": index,
"type": "@(Request.QueryString["type"] ?? "False")"
}, function (result) {
var html = "";
if (result == null || result.list.length > 0) {
$('#pagination2').jqPaginator('option', { totalCounts: result.total });
total = result.list.length;
$.each(result.list, function (i, item) {
//时间格式转换
var pa = /.*\((.*)\)/;
var StartDate = item.TKBeginDate.match(pa)[1].substring(0, 10); //转换起始时间格式
var EndDate = item.TKEndDate.match(pa)[1].substring(0, 10);//转换终止时间格式
var TKStartDate = getTime(StartDate); //起始日期
var TKEndDate = getTime(EndDate); //终止日期
var TKTestDate = TKStartDate.substring(0, 10); //截取日期
var TKBeginTime = TKStartDate.substring(11, 19); //截取起始时间
var TKEndTime = TKEndDate.substring(11, 19);//终止时间
html += "<tr>";
html += "<td>" + (i + 1) + "</td>";
html += "<td>" + item.PlaceTest + "</td>";
html += "<td>" + TKTestDate + "</td>";
html += "<td>" + TKBeginTime + "</td>";
html += "<td>" + TKEndTime + "</td>";
html += "<td>" + item.RegNumTotal + "</td>";
html += "<td>" + item.RegNum + "</td>";
html += "<td>" + item.Explain + "</td>";
html += "<td><a href='javascript:void()' οnclick='TKBook(\"" + item.TKCode + "\"," + item.Type + ")' >预约</a></td>";
html += "</tr>";
});
//$(".table-list tbody").html(html);
$("#select_tableList tbody").html(html);
$("#select_tableList tbody tr").click(function () { $(this).toggleClass("curr"); });
//$(".table-list tbody tr").click(function () { $(this).toggleClass("curr"); });
}
})
}
});
//时间转换
function getTime(/** timestamp=0 **/) {
var ts = arguments[0] || 0;
var t, y, m, d, h, i, s;
t = ts ? new Date(ts * 1000) : new Date();
y = t.getFullYear();
m = t.getMonth() + 1;
d = t.getDate();
h = t.getHours();
i = t.getMinutes();
s = t.getSeconds();
// 可根据需要在这里定义时间格式
return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s);
}
</span>
MVC 之 Ajax 分页查询数据
最新推荐文章于 2021-12-30 14:59:01 发布