I send data to my DataTables and they are valid - but not shown in a table.

I send data to my DataTables and they are valid - but not shown in a table.

PoulMKPoulMK Posts: 1Questions: 1Answers: 0

http://maagaardlogistik.dk/
No debugger code
No errormessages

Hi
I have struggled for nearly a week with DataTable but simply cannot make it work. It accepts the data, but for some reason the data is not shown in a table.

  1. Start my test program by typing
    maagaardlogistik.dk
    in the addressline of your browser.
  2. When the screen appears, start your Chrome-debugger and then the Console Display. There you should be able to see the data I send to DataTables. If not, refresh the page.
  3. If you would like to see how the data is created, start VS Code and load dbr.php.
    There are two places in the switch, case '29' and case '98'.
    No 29 is the one that fetches the data from my database, no 98 is one where I created a few records manually. No 98 works, no 28 is the one I need and so - off course - that is the one that does not.
    Start your VS Code, enter dbr.php and place a breakpoint at the top and run the program as described in 1. or by pressing the refresh button.
    You can then step down to which one of the two you want to look at.

I am fairly convinced that anyone as stunningly good a programmer as you, can solve this problem in a few minutes, but if you don't have the time, please let me know within a few days, so I can find an alternative.

Best regards

Poul

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    This is the JSON response:

    {
      "data": [
        [
          "1",
          "Pk",
          "so",
          "188",
          "a",
          "1",
          "1",
          "1",
          "",
          "2024-10-17 22:02:00",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "1",
          "",
          "749Pkso188a1112024-09-23 23:45:471",
          "",
          ""
        ]
      ]
    }
    

    You row data is in the data object but you set ajax.dataSrc to dataSrc: '',. Remove this option to allow Datatables to find the data in the default data object. See the ajax docs for more details.

    You defined columns.data with the column index value, for example:

        columns: [
          { title: "Nr", data: 0 },
    ...
    

    THis should work but is not necessary.

    Kevin

Sign In or Register to comment.