Server-side not working with this json format [Datatable Editor]

Server-side not working with this json format [Datatable Editor]

BigDataWarehouseBigDataWarehouse Posts: 23Questions: 10Answers: 0
edited March 2020 in Free community support

I'm trying to have serverside pagination (60k records) but my current json is giving me a hard time to archive that:
Here is my json format:

{
    "success": true,
 "technology": [
        {
            "id": 1,
            "name": "Javascript",
            "origin": "web",
            "yearcreated": "1900",

            "IDE": {
                "id": 1,
                "name": "visual studio"
            }
        }
    ]
}

Here is my settings:

 $('#classes').DataTable( {

                    dom: 'Bfrtip',
                    ajax: {
                    url: "URL",
                    type:"POST",
                  dataSrc: 'technology',
                    'Content-Type': 'application/json'
                    },
                     processing: true,
                     serverSide: true,
                    columns: [
                        { data: 'name' },
                    ],
                    select: true,
                    buttons: [
                        { extend: 'create', editor: editor },
                        { extend: 'edit',   editor: editor },
                        { extend: 'remove', editor: editor },
                        {
                            extend: 'csv',
                            text: 'Export CSV',
                            className: 'btn-space',
                            exportOptions: {
                                orthogonal: null
                            }
                        },
                        {
                            text: 'Import CSV',
                            action: function () {
                                uploadEditor.create( {
                                    title: 'CSV file import'
                                } );
                            }
                        },
                        {
                            extend: 'selectAll',
                            className: 'btn-space'
                        },
                        'selectNone',
                    ]
                } );

My table just shows a list of technologies e.i javascript [datasrc: Javascript] etc... but when i apply:

serverSide: true

it doesnt work and pagination is ignored and I get:

Showing 0 to 0 of 0 entries (filtered from NaN total entries ...

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • kthorngrenkthorngren Posts: 21,141Questions: 26Answers: 4,918

    What are you using for the server script?

    Does it support the server side protocol as described here?

    Your server script needs to perform DB queries that support paging like using SQL LIMIT and OFFSET.

    Kevin

  • BigDataWarehouseBigDataWarehouse Posts: 23Questions: 10Answers: 0

    Hi @kthorngren, many thanks for your response,

    I'm using mysql database,
    I built an api in play framework that returns a json object (60k + ) records,
    i thought of using DT serve-side processing feature

    • I look forward to your reply
  • kthorngrenkthorngren Posts: 21,141Questions: 26Answers: 4,918

    Using the server side option requires the server code to perform the paging and return only the rows to be displayed on the page. The client sends parameters to the server indicating things like the page being requested, number of rows on the page, ordering and search information. It is expected that the server script process these parameters and return only the data for the page.

    Kevin

This discussion has been closed.