Using Server Side Processing using Search and Length = -1

Using Server Side Processing using Search and Length = -1

noahduncannoahduncan Posts: 2Questions: 1Answers: 0
edited October 2015 in Free community support

I'm trying to do a search using server side processing when the table length parameter has been set to show all records (-1). For some reason the table displays no rows when doing this search even though the data comes in from the server as expected.

Here is my debug output for this state: http://debug.datatables.net/avihit

Here is a screenshot of the output: http://nimb.ws/0kLf1Y

I've confirmed that the server side code works correctly for Length = -1 and Search = '' as well as Length != -1 and Search != ''. Does data tables not support showing all records in conjunction with a search criterion?
If it does support all / search, does anyone have any clues as to what the issue could be?

Thanks!
~Noah

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,096Questions: 1Answers: 10,390 Site admin
    Answer ✓

    The server is responding with aaData being an object:

        "aaData": {
            "2": {
                "0": "",
                "DT_RowId": 1375,
                "1": " 2014 New York Benefit Gala",
                "2": "Approved",
                "3": "Main Program",
                "4": "11\/10\/14 6:00 PM",
                "5": "11\/11\/14 12:00 AM",
                "6": ""
            },
            "55": {
                "0": "",
                "DT_RowId": 146,
                "1": "10th Annual New York Cares Soiree",
                "2": "Approved",
                "3": "Main Program",
                "4": "3\/6\/14 6:30 PM",
                "5": "3\/6\/14 10:30 PM",
                "6": ""
            },
    

    That is not valid for DataTables. The data (or aaData) property must have an array value - objects are not supported there. The values in the array can be objects, but it must be an array itself.

    Allan

  • noahduncannoahduncan Posts: 2Questions: 1Answers: 0

    Allan:

    Genius! After php stripped out unwanted rows, it would convert the result set into an object when converting to JSON because keys were non-sequential. array_values() to the rescue!

    Thanks a ton!

  • allanallan Posts: 63,096Questions: 1Answers: 10,390 Site admin

    Excellent - good to hear that helped :-)

    Regards,
    Allan

This discussion has been closed.