Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 526.9k

Table not showing as Jquery Datatable

May 30 2021 10:07 AM
Hi
 
  It is showing error - 
Uncaught TypeError: Cannot read property 'mData' of undefined
at HTMLTableCellElement.<anonymous> (jquery.dataTables.min.js:90)
 
 
 Location.js
 
$(document).ready(function () {
$("#tblLocation").dataTable({
});
});
 
 ***********************
@model IEnumerable<MyApplication.Models.Location>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
</head>
<body>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" onclick="clearTextBox();">Add New Location</button><br /><br />
<table class="table" id="tblLocation">
<tr>
<th>
@Html.DisplayNameFor(model => model.Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.IsActive)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsActive)
</td>
<td><a href="#myModal" data-id="@item.Id" class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal"><span class="glyphicon glyphicon-pencil"></span></a>
<a href="#myModal" data-id="@item.Id" class="btn btn-primary btn-xs" data-title="Delete" data-toggle="modal"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
}
</table>
</body>
</html>
<script src="~/Scripts/Appjs/Location.js"></script>
 
 
Thanks 

Answers (2)