Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81920

Angular 2 / 4 Server Side Processing for Datatables not displaying data

$
0
0

Angular 4.2.4
Angular-Datatables 4.2.0
datatables 1.10.16
jQuery 3.2.1
Angular-cli 1.4.0
Node 6.11.4
npm 3.10.10

When the data returns back from the server, it's never populated into the table.

Html
<table datatable [dtOptions]="dtOptions"></table>

Component

ngOnInit() {

    this.dtOptions = {
        ajax: {
            url: "http://localhost:8880/nmets/api/manifest/search",
            type: 'POST',
            contentType: 'application/json; charset=UTF-8',
            error: function(xhr, error, code) { console.log(error); },
            success: function(result) {console.log(JSON.stringify(result))},
            data: function(data) {
                return JSON.stringify(data);
            }
        },
        columns: [

            { data: "departureTime", title: 'Departure Time', }

        ],
        processing: true,
        serverSide: true,
        pagingType: 'full_numbers',
        pageLength: 25,
    };
}

When the page loads I see the table header ("Departure Time") and I see the word "Processing...". I see the Post request and the server responds as follows (shortened):

Server Response

    {"draw":1,
    "recordsTotal":109,
    "recordsFiltered":109,
    "data":[
    {"departureTime":"2:18 pm"},
    {"departureTime":"2:55 pm"},
    {"departureTime":"8:54 pm"},
    {"departureTime":"9:10 pm"},
    {"departureTime":"12:28 am"},
    {"departureTime":"12:33 am"},
    ...
    ]}

I can see the result from the 'success' callback, but the table does not get populated, and the 'Processing...' also continues to display.

Any Ideas?

Thanks


Viewing all articles
Browse latest Browse all 81920

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>