In Product.cshtml:
@model List<Product>
Product List
Title | ISBN | Author | Price | Category |
---|
@section Scripts{
}
In product.js:
$(document).ready(function () {
loadDataTable();
});
function loadDataTable() {
dataTable = $('#tableData').DataTable({
"ajax": { url: '/admin/product/getall' },
"columns": [
{ data: 'title', "width": "15%" },
{ data: 'isbn', "width": "15%" },
{ data: 'listPrice', "width": "15%" },
{ data: 'author', "width": "15%" },
{ data: 'category.name', "width": "15%" }
]
});
}
Error:
jquery.min.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'sClass')
at et (dataTables.min.js:4:14349)
at At (dataTables.min.js:4:29734)
at wt (dataTables.min.js:4:22944)
at Mt (dataTables.min.js:4:34015)
at HTMLTableElement.<anonymous> (dataTables.min.js:4:7044)
at Function.each (jquery.min.js:2:3003)
at S.fn.init.each (jquery.min.js:2:1481)
at S.fn.init.V [as dataTable] (dataTables.min.js:4:1327)
at H.fn.DataTable (dataTables.min.js:4:93325)
at loadDataTable (product.js:12:33)
How to solve the error?