WEB most jól működik Datatables-sel.
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
@page
|
||||
@model WorkFlowCheck.Web.Pages.BaseStock.CheckPoints.CheckPointEditPageModel
|
||||
@{
|
||||
ViewData["Title"] = "Ellenőrzési pont";
|
||||
var checkpointId = Model.CheckPoint.Id;
|
||||
var url = Url.Page("./CheckPointEditPage", "LoadCheckListTemplateRows", new { id = checkpointId });
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<input type="hidden" id="checkPointEditUrl" value="@url" />
|
||||
|
||||
<div>
|
||||
<form method="post">
|
||||
<input type="hidden" id="hiddenCheckPointId" value="@Model.CheckPoint.Id" />
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="CheckPoint.ShortName"></label>
|
||||
<input asp-for="CheckPoint.ShortName" class="form-control" />
|
||||
<span asp-validation-for="CheckPoint.ShortName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="CheckPoint.Code"></label>
|
||||
<input asp-for="CheckPoint.Code" class="form-control" />
|
||||
<span asp-validation-for="CheckPoint.Code" class="text-danger"></span>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Mentés</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-primary float-right">Új elem hozzáadása</button>
|
||||
</div>
|
||||
<div>
|
||||
<table id="tbCheckPointsEditPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>RowIndex</th>
|
||||
<th>OperationDescription</th>
|
||||
<th>AnswerType</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>RowIndex</th>
|
||||
<th>OperationDescription</th>
|
||||
<th>AnswerType</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
const table = new DataTable('#tbCheckPointsEditPage', {
|
||||
ajax: {
|
||||
url: $('#checkPointEditUrl').val(),
|
||||
type: "GET",
|
||||
dataSrc : "data"
|
||||
},
|
||||
columns: [
|
||||
{ data: "id" },
|
||||
{ data: "rowIndex" },
|
||||
{ data: "operationDescription" },
|
||||
{ data: "answerType" },
|
||||
{ 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": 4,
|
||||
"className": "text-center",
|
||||
"width": "15%"
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
});
|
||||
$('#tbCheckPointsEditPage').on('click', '.edit-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
|
||||
});
|
||||
$('#tbCheckPointsEditPage').on('click', '.delete-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
|
||||
{
|
||||
public class CheckPointEditPageModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IBaseStockService _baseStockService;
|
||||
|
||||
[BindProperty]
|
||||
public CheckPointDTO CheckPoint { get; set; }
|
||||
|
||||
public CheckPointEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
|
||||
{
|
||||
_baseStockService = baseStockService;
|
||||
_logger = logger;
|
||||
}
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
CheckPoint = await _baseStockService.GetCheckPoint(id);
|
||||
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
|
||||
{
|
||||
CheckPoint = await _baseStockService.GetCheckPoint(id);
|
||||
return new JsonResult(new { data = CheckPoint.CheckListTemplateRowDTO });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
|
||||
{
|
||||
public class CheckPointsPageModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IBaseStockService _baseStockService;
|
||||
public CheckPointsPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
|
||||
{
|
||||
_logger = logger;
|
||||
_baseStockService = baseStockService;
|
||||
}
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadCheckPoints()
|
||||
{
|
||||
var results = await _baseStockService.GetAllCheckPoints();
|
||||
return new JsonResult(new { data = results });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user