I am using jQuery DataTables 1.9.4. On trying to use the datatable module I am getting the above error. Going through SO, I have seen a lot of people advising to use the uppercase DataTable({})
instead of the lowercase dataTable({})
, but still get the error.
var table = $("#example1").DataTable();
$('#example1 tbody').on('click', 'tr', function () {
var data = table.row(this).data();
});
Note this is an ASP.NET MVC Project
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.FirstName)</th>
<th>@Html.DisplayNameFor(model => model.Surname)</th>
<th>@Html.DisplayNameFor(model => model.MiddleName)</th>
<th>@Html.DisplayNameFor(model => model.DateOfBirth)</th>
<th>@Html.DisplayNameFor(model => model.Department)</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.FirstName)</td>
<td>@Html.DisplayFor(modelItem => item.Surname)</td>
<td>@Html.DisplayFor(modelItem => item.MiddleName)</td>
<td>@Html.DisplayFor(modelItem => item.DateOfBirth)</td>
<td>@Html.DisplayFor(modelItem => item.Department)</td>
</tr>
}
</tbody>
</table>
You're using jQuery DataTables 1.9.4.
API method row()
is only available in jQuery DataTables 1.10+.
See if you can upgrade your library, it is backward compatible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.