2024-05-05 23:46:21 +04:00

74 lines
1.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
ViewData["Title"] = "Mails";
}
<div class="text-center">
<h1 class="display-4">Mails</h1>
</div>
<div class="text-center">
<table id="mailsTable" class="table">
<thead>
<tr>
<th>
Mail's date'
</th>
<th>
Title
</th>
<th>
Text
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="text-center">
<div>
Page: <input type="number" id="pageNum" value="1" min="1" /> Page Size: <input type="number" id="pageSize" value="2" min="1" />
</div>
</div>
</div>
<script>
$(document).ready(function () {
// Инициализируем значения NumericUpDown с текущими значениями
var pageNum = $('#pageNum').val();
var pageSize = $('#pageSize').val();
// Функция для загрузки данных с сервера
function loadMails(pageNum, pageSize) {
$.ajax({
url: '/Home/LoadMails',
type: 'POST',
data: { pageNum: pageNum, pageSize: pageSize },
success: function (data) {
// Очищаем текущие данные
$('#mailsTable tbody').empty();
// Заполняем таблицу новыми данными
$.each(data, function (index, item) {
var row = $('<tr>');
row.append($('<td>').text(item.dateDelivery));
row.append($('<td>').text(item.subject));
row.append($('<td>').text(item.body));
$('#mailsTable tbody').append(row);
});
},
error: function () {
alert('Error loading mails');
}
});
}
// Загружаем данные при инициализации страницы
loadMails(pageNum, pageSize);
// Обработчик изменений для NumericUpDown
$('#pageNum, #pageSize').change(function () {
pageNum = $('#pageNum').val();
pageSize = $('#pageSize').val();
loadMails(pageNum, pageSize);
});
});
</script>