1

I am typing in the search box in an attempt to narrow my results. When I am typing the screen flashes like it is trying to narrow the results but the results do not change.

<script>
    $(document).ready(function () {

       var table =  $('#activeProjects').dataTable({
            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "../api/Project/GetAll/",
                "dataSrc": ""
            },

            "columns": [
            { "data": "ProjectName" },
            { "data": "ProjectNumber" },
            { "data": "ProjectManager" },
            { "data": "ProjectArchitect" }
            ]
       });
    });
</script>

I get back a List of data from the server but I an unable to search?

1 Answer 1

4

When using server side data, DataTables won't grab all data and filter it on the client, instead it will rely on the server to do all the processing and send only the parts that will be displayed to the user.

You have to implement the search in your server side script, in this case ../api/Project/GetAll/.

DataTables sends a few parameters back to the server. Look for the parameters search[value] and columns[i][searchable] and filter your data accordingly.

Sign up to request clarification or add additional context in comments.

4 Comments

Could you show an example of what the api Action should look like?
I'm not sure I understand what you mean by "api Action". If you want to see an implementation of the server side processing for DataTables, check out DataTables's Server-side processing example page, below the data table there is a box, click "Server-side script" and check that out. Actually, that file and the ssp.class.php file are included in the distribution of the plugin under \examples\server_side\scripts.
That is my problem then, I am running the server-side in ASP.NET WEB API 2. I will try and find examples of it in that. Thanks
The arguments sent back to your Web API will be exactly the same as the php examples. DataTables is server-agnostic. Just read parameters from HttpContext.Request and filter your data server-side accordingly (e.g. LINQ, dynamic SQL, etc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.