Server-side processing + all data returned but column filter + pagination + search not working

Server-side processing + all data returned but column filter + pagination + search not working

hattricknzhattricknz Posts: 10Questions: 6Answers: 0

I have the following fiddle example that I am trying to get working with a database.

The fiddle has 2 rows for test data and the search and column search works.

Now with my example connecting to the database has 2 files an index.php file and a employee-grid-data3.php file.

index.php looks very similar to the fiddle, but it has the following code, and the tbody/rows will be filled by data returned from the db

        <script type="text/javascript" language="javascript" >
            $(document).ready(function() {
                var dataTable = $('#employee-grid').DataTable( {
                    "processing": true,
                    "serverSide": true,
                    "ajax":{
                        url :"employee-grid-data3.php", // json datasource
                        type: "post",  // method  , by default get
                        error: function(){  // error handling
                            $(".employee-grid-error").html("");
                            $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server -- startagain1-index3.php </th></tr></tbody>');
                            $("#employee-grid_processing").css("display","none");
                            
                        }
                    }
                } );
            } );
        </script>

my index.php file points at employee-grid-data3.php which looks like this here with the relevant details filled in.

If i check this in the browser, I can see the data that is returned looks like:

{"sEcho":0,
"iTotalRecords":"999",
"iTotalDisplayRecords":"999",
"aaData":[["2015-10-06","427","60","137765","Samsung Korea","Samsung SM-G900I","$39 Plan"],
["2015-10-06","592","620","0","Apple Inc","Apple iPhone 6 (A1586)","PREPAY  STD - TRIAL - #16"],
...

**Now the end result is all the data is returned and displayed on one page. Which means that the pagination, search adn column search is not working. What do I have to do for my datatables to accept the data returned in this format? **

As an aside I have another employee-grid-data.php file that returns data like this and the search and pagination works.

{"draw":1,
"recordsTotal":999,
"recordsFiltered":999,
"data":[
["2015-10-06","717","290","16019540","Apple Inc","Apple iPhone 5S (A1530)","$29 Plan"],
...

Can anyone advise where I am going wrong?

This discussion has been closed.