dataTable information is read from the database, But they are not displayed in the dataTable I use inspect to see the information, but the table is not displayed at all What's wrong? The code is as follows
public PartialViewResult OnGetViewAllPartial()
{
lstLevel = _CourseLevelApplication.GetCourseLevelForDisplay();
return new PartialViewResult
{
ViewName = "_ViewAll",
ViewData = new ViewDataDictionary<IEnumerable<CoursLevelViewModel>>(ViewData, lstLevel)
};
}
<table id="datatable" class="table table-striped table-bordered" >
<thead>
<tr>
<th>#</th>
<th>title</th>
<th>action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>@item.Title</td>
<td>
<a onclick="jQueryModalGet('?handler=CreateOrEdit&id=@item.Id','Edit level')" class="btn btn-info text-white"> Edit</a>
<form method="post" asp-page="Index" asp-route-id="@item.Id" asp-page-handler="Delete" onsubmit="return jQueryModalDelete(this)" class="d-inline">
<button type="submit" class="btn btn-danger text-white"> Delete</button>
</form>
</td>
</tr>
}
</tbody>
</table>
@section Scripts {
<script src="~/AdminTheme/assets/datatables/jquery.dataTables.min.js"></script>
<script src="~/AdminTheme/assets/datatables/dataTables.bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#datatable').dataTable();
});
</script>
}
Try putting these into the head section into the layout page.
<script src="~/AdminTheme/assets/datatables/jquery.dataTables.min.js"></script>
<script src="~/AdminTheme/assets/datatables/dataTables.bootstrap.js"></script>