Server side searching problem

Server side searching problem

scarfeelscarfeel Posts: 7Questions: 2Answers: 0
edited December 2020 in Free community support

Hello all i got a search field from server side. I`m using Wordpress ( i integrated datatables with WP Posts and Meta Data ). The problem is, when i recieve the data i see it in Response tab, but Table is blank. Any suggestions ?

$('#example').DataTable({
                                "bSort": false,
                                "serverSide": true,
                                select: true,
                                "columnDefs": columnDef,
                                "bServerSide": true,
                                "paging": false,
                                dom: "Bfrtip",

Here is Json response filtered by my search field:

retracted

This question has an accepted answers - jump to answer

Answers

  • scarfeelscarfeel Posts: 7Questions: 2Answers: 0

    Bump

  • kthorngrenkthorngren Posts: 20,369Questions: 26Answers: 4,777

    Your data looks like this:

        "data": {
            "0": {
                "DT_RowId": 197,
                "ID": 197,
                ....
                "estimated-finish": "2017-06-13",
                "date-finished": "2017-06-05"
            },
            "1": {
                "DT_RowId": 196,
                "ID": 196,
                ....
                "estimated-finish": "2017-06-12",
                "date-finished": ""
            },
    

    I think it should be an array of objects as described here:
    https://datatables.net/manual/data/#Objects

    I think your JSON should look more like this:

        "data": [
            {
                "DT_RowId": 197,
                "ID": 197,
                ....
                "estimated-finish": "2017-06-13",
                "date-finished": "2017-06-05"
            },
            {
                "DT_RowId": 196,
                "ID": 196,
                ....
                "estimated-finish": "2017-06-12",
                "date-finished": ""
            },
            ....
              ]
    

    Kevin

  • scarfeelscarfeel Posts: 7Questions: 2Answers: 0

    I will try it, but i think it will not work, because initial data in table ( first load when user come on page, looks exactly the same)

  • scarfeelscarfeel Posts: 7Questions: 2Answers: 0

    Okay, i tried it. When i put manually JSON with that structure, the PHP gives me error 500.

  • kthorngrenkthorngren Posts: 20,369Questions: 26Answers: 4,777
    Answer ✓

    How are you defining your columns (its not shown in the code above). The structure of your columns definition will determine how the data needs to be structured in your JSON.

    Kevin

This discussion has been closed.