Datatables/Angular and Server side processing

Datatables/Angular and Server side processing

leeguthleeguth Posts: 19Questions: 1Answers: 0
edited October 2014 in Free community support

I've tried to use your example for server side processing because I am retrieving a very large list of data. I am using Angular and hopefully have copied your example correctly, but I think I am missing something as no data shows. I can run the php file being called to retrieve the data and on the screen it is retrieving it from my database. I'm sure I am missing something very small...all I get is the heading of the table.

Here is my HTML for my table:

    <table id="consolidatedPageTable" class="table table-condensed table-striped table-bordered" ts-wrapper>
        <thead>
            <tr>
                <th ts-criteria="source" ts-default="descending">Source</th>
                <th ts-criteria="mailingDate | lowercase">Mailing Date</th>
                <th ts-criteria="status | lowercase">Status</th>
                <th ts-criteria="cpi | lowercase">CPI</th>
                <th ts-criteria="userId | lowercase">User ID</th>
                <th ts-criteria="shorttext | lowercase">Program</th>
                <th ts-criteria="customerNumber | lowercase">Customer Number</th>
                <th ts-criteria="customerName | lowercase">Customer Name</th>
                <th ts-criteria="dlDate | lowercase">DL Date</th>
            </tr>
        </thead>
    </table>

Here is my controller:

app.controller('ConsolidatedController', function($scope,$rootScope,$http,$filter,$location,$routeParams) {
    
    createTable();
    
    
    $scope.tableFilter = {
        "source":"",
        "mailingDate":"",
        "status":"",
        "cpi":"",
        "userId":"",
        "shorttext":"",
        "customerNumber":"",
        "customerName":"",
        "dlDate":""
    };

    $scope.tableFilter[$routeParams.filterColumn] = $routeParams.filterValue;

    $scope.resetFilters = function(){
        $scope.tableFilter = {
            "source":"",
            "mailingDate":"",
            "status":"",
            "cpi":"",
            "userId":"",
            "shorttext":"",
            "customerNumber":"",
            "customerName":"",
            "dlDate":""
        };
        $location.path('consolidated');
    }

});

function createTable(){
    $(function(){
        var table = $('#consolidatedPageTable').dataTable({
            "destroy": true,    
            "processing": true,
            "serverSide": true,
            "ajax": "scripts/consolidatedTable.php",        
            "columnDefs": [
            {
                "targets": [9],
                "visible": false,
                "searchable": true
            }
        ]
        });
    })
}

Here is the consolidatedTable.php (with some specific information deleted)

$table = "consolidated";
$primaryKey = "customerNumber";

$columns = array();
$columns[] = array('db' => 'source' , 'dt' => 0);
$columns[] = array("db"=>"mailingDate","dt"=>1);
$columns[] = array("db"=>"status","dt"=>2);
$columns[] = array("db"=>"cpi","dt"=>3);
$columns[] = array("db"=>"userId","dt"=>4);
$columns[] = array("db"=>"shorttext","dt"=>5);
$columns[] = array("db"=>"customerNumber","dt"=>6);
$columns[] = array("db"=>"customerName","dt"=>7);
$columns[] = array("db"=>"dlDate","dt"=>8);

$sql_details = array("user" => "XXX","pass" => "XXX","db" => "XXX","host" => "XXX");
require("ssp.class.php");

echo json_encode(SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ));

I am using a non-changed ssp.class.php file so there is nothing specific in there. As I mentioned, the consolidatedTable.php does retrieve and return the correct data (looks similar to your example)

This question has an accepted answers - jump to answer

Answers

  • leeguthleeguth Posts: 19Questions: 1Answers: 0

    anyone have any ideas?

  • leeguthleeguth Posts: 19Questions: 1Answers: 0

    I still can't get this to show anything. I get no errors.

    One difference I noticed is that the data shown in the example has a '1' for display but my data has a '0' - does that make a difference? I can't see what I am missing. I have tried removing stuff from my controller so the only thing there is the call to the createtable function. I also stripped down the HTML so it doesn't have the "ts" tags.

    Please if someone can help, it would be greatly appreciated.

  • mfikmfik Posts: 1Questions: 0Answers: 1
    Answer ✓

    What does your data look like? Can you post the response?

  • leeguthleeguth Posts: 19Questions: 1Answers: 0

    Well, it end up things were changed around and someone revamped the code and those changes now let it to work. Thank you anyway.

This discussion has been closed.