JQuery datatables ajax datasource issue

I followed the example shown on the datatables website for making an ajax request and I can't seem to get it to work with the datatables nuget package. The model binder is insane because the lookup 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 search value cannot be null. If the search fails, enter an empty string. Parameter name: value

+3


source to share


1 answer


If you are using server-side processing you need to add 'serverSide': true

DataTables as parameter, see the following code:



$('#users-table').dataTable({
  'serverSide': true,
  'ajax': '@Url.Action("ListUsers", "Businesses",null,Request.Url.Scheme)'
});

      

+3


source







All Articles