I'm working on a project where I have to use a jQuery datatable for efficient searching. Unfortunately, jQuery datatable searching, page filtring are not working properly as it has to work.
Here is the code which i used for said purpose. Here is the image link too
<link rel="stylesheet" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#dataTable").DataTable();
});
</script>
razor view code.
<table id="dataTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Page)
</th>
<th>
@Html.DisplayNameFor(model => model.cityDisplayName)
</th>
<th>
@Html.DisplayNameFor(model => model.countryDisplayName)
</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>
@Html.DisplayNameFor(model => model.Page)
</th>
<th>
@Html.DisplayNameFor(model => model.cityDisplayName)
</th>
<th>
@Html.DisplayNameFor(model => model.countryDisplayName)
</th>
<th></th>
</tr>
</tfoot>
@foreach (var item in Model.ListVisitorLocation)
{
<tbody>
<tr>
<td>
@Html.DisplayFor(modelItem => item.Page)
</td>
<td>
@Html.DisplayFor(modelItem => item.cityDisplayName)
</td>
<td>
@Html.DisplayFor(modelItem => item.countryDisplayName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ConnectionId }) |
@Html.ActionLink("Details", "Details", new { id = item.ConnectionId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ConnectionId })
</td>
</tr>
</tbody>
}
</table>
What happens is the search only applies the operation on the first row of the table.