WEB most jól működik Datatables-sel.

This commit is contained in:
2025-03-11 16:54:50 +01:00
parent e5b1649c42
commit 8f9e5df847
11 changed files with 370 additions and 7 deletions
@@ -0,0 +1,74 @@
@page
@model WorkFlowCheck.Web.Pages.BaseStock.CheckPoints.CheckPointsPageModel
@{
ViewData["Title"] = "Ellenőrzési pontok";
}
<h1>@ViewData["Title"]</h1>
<div class="d-flex justify-content-end">
<button class="btn btn-primary float-right">Új elem hozzáadása</button>
</div>
<div>
<table id="tbCheckPointsPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Short Name</th>
<th>Code</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>Short Name</th>
<th>Code</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
const table = new DataTable('#tbCheckPointsPage', {
ajax: {
url: "@Url.Page("./CheckPointsPage", "LoadCheckPoints")",
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "shortName" },
{ data: "code" },
{ data: null, render: function (data, type, row) {
return `<button class="btn btn-primary edit-btn" data-id="${row.id}">Módosítás</button>
<button class="btn btn-danger delete-btn" data-id="${row.id}">Törlés</button>
`;
}}
],
columnDefs: [
{
"targets": 0,
"visible": false
},
{
"targets": 3,
"className": "text-center",
"width": "15%"
}
],
processing:true
});
$('#tbCheckPointsPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./CheckPointEditPage")?id=${row.id}`;
});
$('#tbCheckPointsPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
});
</script>
}