Reputation: 20004
I've followed the example shown on the datatables website for making an ajax request and I can't get it to work with the data tables nuget package. The model binder is mad because the search value is null and expects it to be an empty string.
Controller:
public JsonResult ListUsers([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest request)
View:
<table id="users-table" class="table table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
</table>
$(function() {
$('#users-table').dataTable({
ajax: '@Url.Action("ListUsers", "Businesses",null,Request.Url.Scheme)'
});
});
The value of the search cannot be null. If there's no search performed, provide an empty string. Parameter name: value
Upvotes: 3
Views: 1243
Reputation: 58920
If you're using server-side processing, you need to add 'serverSide': true
as DataTables parameter, see the code below:
$('#users-table').dataTable({
'serverSide': true,
'ajax': '@Url.Action("ListUsers", "Businesses",null,Request.Url.Scheme)'
});
Upvotes: 3