HU a datatables-hez

This commit is contained in:
2025-03-19 09:59:42 +01:00
parent 2fd147bb36
commit f74922d01e
10 changed files with 78 additions and 18 deletions
@@ -32,10 +32,12 @@
</div>
</form>
</div>
<br />
<div class="card shadow p-4">
<div class="d-flex justify-content-end">
<button class="btn btn-primary float-right">Új elem hozzáadása</button>
<button class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
<i class="bi bi-plus-square"></i>
</button>
</div>
<table id="tbCheckPointsEditPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
@@ -89,15 +91,16 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbCheckPointsEditPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./CheckListTemplateRowEditPage")?id=${row.id}`;
});
$('#tbCheckPointsEditPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
@@ -112,7 +115,7 @@
}
});
});
$("#saveCheckPoint").click(function () {
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
var formData = getFormAsNestedObject('#checkPointForm');
@@ -59,7 +59,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbCheckPointsPage').on('click', '.edit-btn', function ()
@@ -54,7 +54,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbEquipmentsPage').on('click', '.edit-btn', function ()
@@ -54,7 +54,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbLocationsPage').on('click', '.edit-btn', function ()
@@ -56,7 +56,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#newRoleBtn').on('click', function ()
@@ -5,10 +5,12 @@
@{
ViewData["Title"] = "Ellenőrzési pont";
var UserId = Model.UserDTO.Id;
var url = Url.Page("./UserEditPage", "LoadRoles", new { id = UserId });
var urlPost = Url.Page("./UserEditPage", "Save");
}
<h1>@ViewData["Title"]</h1>
<input type="hidden" id="UserEditUrl" value="@url" />
<input type="hidden" id="UserEditPostUrl" value="@urlPost" />
<div class="card shadow p-4">
@@ -52,9 +54,48 @@
</div>
</form>
</div>
<br></br>
<div class="card shadow p-4">
<table id="tbUserPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Role Name</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>Role Name</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
console.log($('#UserEditUrl').val());
const table = new DataTable('#tbUserPage', {
ajax: {
url: $('#UserEditUrl').val(),
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "roleName" }
],
columnDefs: [
{
"targets": 0,
"visible": false
}
],
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$("#saveUser").click(function () {
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
@@ -98,7 +139,7 @@
});
$(document).ready(function () {
const $form = $("#userForm");
const $form = $("#UserForm");
$form.validate({
errorClass: "text-danger small",
@@ -46,5 +46,10 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
return new JsonResult(new { success = false });
}
public async Task<JsonResult> OnGetLoadRoles(int id)
{
UserDTO = await _userService.GetUser(id);
return new JsonResult(new { data = UserDTO.RoleDTO });
}
}
}
@@ -7,7 +7,9 @@
<div class="card shadow p-4">
<div class="d-flex justify-content-end">
<button id="newUserBtn" class="btn btn-primary float-right new-btn">Új elem hozzáadása</button>
<button id="newUserBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új felhasználó">
<i class="bi bi-plus-square"></i>
</button>
</div>
<table id="tbUsersPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
@@ -63,7 +65,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#newUserBtn').on('click', function ()
@@ -71,13 +74,13 @@
console.log('New button clicked!"');
window.location.href = `@Url.Page("./UserEditPage")?id=0`;
});
$('#tbUsersPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./UserEditPage")?id=${row.id}`;
});
$('#tbUsersPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
@@ -59,7 +59,8 @@
}
],
processing:true
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#newUserRoleBtn').on('click', function ()