DataTables ASP.Net Core Razor Page

DataTables ASP.Net Core Razor Page

vansinvansin Posts: 15Questions: 4Answers: 0

I am very new to this. Below is the HTML for my table in a Razor page in an ASP.net core project using a model populated with data from database. How do I construct the Javascript section to make the datatable work for this table? I realize the simple one line example below doesn't work but not sure where to go.

$(document).ready( function () {
$('#myTable').DataTable();
} );

Here is the table HTML code:

''''

@foreach (var item in Model.CornerstoneTicketQuery) { }
@Html.DisplayNameFor(model => model.CornerstoneTicketQuery[0].LocationName) @Html.DisplayNameFor(model => model.CornerstoneTicketQuery[0].ScaleTicketId)
@Html.DisplayFor(modelItem => item.LocationName) @Html.DisplayFor(modelItem => item.ScaleTicketId)

'''

Answers

  • vansinvansin Posts: 15Questions: 4Answers: 0

    Here is the HTML table code again.

    @foreach (var item in Model.CornerstoneTicketQuery) { }
    @Html.DisplayNameFor(model => model.CornerstoneTicketQuery[0].LocationName) @Html.DisplayNameFor(model => model.CornerstoneTicketQuery[0].ScaleTicketId)
    @Html.DisplayFor(modelItem => item.LocationName) @Html.DisplayFor(modelItem => item.ScaleTicketId)
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    There are a few thread on the forum discussing this, such as here, and other external resources, such as here.

    Colin

This discussion has been closed.