When only one row of data is available, why does my table show "no data in table"?

When only one row of data is available, why does my table show "no data in table"?

lpacelpace Posts: 12Questions: 6Answers: 0

test here: http://aomppapp.gmaom.us:8080/get_cotg_form?id=103329020220919_delivery.html
debugger code: epewiw
error: "No data available in table"
My JSON response only contains just 1 row of data but the table displays this message instead of the data.

Is the format of my data incorrect or my initialization wrong?

$('#rmas').DataTable({                 
  "ajax":
  {"url": "http://aomppapp.gmaom.us:9090/get_RMA?NAME_ID="+customerno,                        
  },
   "columns": [
     { "data": "Record.RECID" },
     { "data": "Record.QSHP" },
     { "data": "Record.PART_NO" },
     { "data": "Record.DESCRIPTION" },
   ],
 
}); 

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    Answer ✓

    This is the XHR response:

    {
        "data": {
            "Record": {
                "ID": "1132",
                "SYS_STBR": "18\/01",
                "RECID": "PQ21178",
                "DEALER_CODE_DV": "118480",
                "NAME_ID": "1033290",
                "NAME": "GARBER BUICK",
                "PART_NO": "GM84425985",
                "DESCRIPTION": "DECAL PKG",
                "QSHP": "-1",
                "RETURN_REASON": "BOB<br\/>WRONG PART ORDERED<br\/><br\/><br\/>X",
                "PO_NO": "3691229",
                "OPEN_DATE": "09\/12\/22",
                "EXTSALE": "-112.50",
                "BWARR": "112.50",
                "EXT_BWARR": "-112.50",
                "SHIP_VIA": "ROUTE 14",
                "CTRMN_NAME": "DION WALKER"
            }
        }
    }
    

    Datatalbes expects the row data to be in an array even if its in one row. See the Ajax docs for more details. The response should look more like this:

    {
        "data": [
          {
            "ID": "1132",
            "SYS_STBR": "18\/01",
            "RECID": "PQ21178",
            "DEALER_CODE_DV": "118480",
            "NAME_ID": "1033290",
            "NAME": "GARBER BUICK",
            "PART_NO": "GM84425985",
            "DESCRIPTION": "DECAL PKG",
            "QSHP": "-1",
            "RETURN_REASON": "BOB<br\/>WRONG PART ORDERED<br\/><br\/><br\/>X",
            "PO_NO": "3691229",
            "OPEN_DATE": "09\/12\/22",
            "EXTSALE": "-112.50",
            "BWARR": "112.50",
            "EXT_BWARR": "-112.50",
            "SHIP_VIA": "ROUTE 14",
            "CTRMN_NAME": "DION WALKER"
        }
         ]
    }
    

    Kevin

  • lpacelpace Posts: 12Questions: 6Answers: 0

    thanks @kthorngren, changing my server program that generates the data to match your example array solved it.

Sign In or Register to comment.