DataTables warning: - Requested unknown parameter 'X' for row 0, col

DataTables warning: - Requested unknown parameter 'X' for row 0, col

islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1
edited May 2018 in Free community support

I'm getting this alert

DataTables warning: table id=achats_table - Requested unknown parameter 'Fournisseur' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

and my table is empty, I have no idea how to debug this. Help.

I've read that it's because my tbody and thead sizes do not match, but they do. Even tho I weridly find that Datatables creates a thead inside my tbody, I just noticed that. Any idea why would it do that?

Replies

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    The link provided in the error has troubleshooting steps:
    http://datatables.net/tn/4

    Try those and let us know what you find. Looks like you have object based data being returned but did not define columns.data.

    Kevin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1
    edited May 2018

    I tried following the steps, I do have data defined :(

    for (var i in headerData[0]) {
        columns.push({data: headerData[0][i]});
    }
    

    This gives me :

    0:{data: "A", mData: "A"}
    1:{data: "B", mData: "B"}
    2:{data: "C", mData: "C"}
    3:{data: "D", mData: "D"}
    4:{data: "F", mData: "% F"}
    5:{data: "G", mData: "G"}
    6:{data: "H", mData: "H"}
    7:{data: "I", mData: "I"}
    8:{data: "J", mData: "J"}
    9:{data: "K", mData: "K"}
    10:{data: "L", mData: "L"}
    11:{data: "M", mData: "M"}
    12:{data: "N", mData: "N"}
    
    
  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Requested unknown parameter 'Fournisseur'

    I don't see that in your output of columns. Maybe you can post more of your code and the data so we can see how you are building your columns, applying them to Datatables and how the data maps to the columns.

    Kevin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1
    edited May 2018

    I changed my columns to letters from A to N, it IS indeed there, I just changed the names, that isn't the problem :) I can't post the code/data, as there are 400K data with headers that vary, the code is quite complicated to be shared... I just thought you might have an idea about where could it be coming from. Like if I have data and mData at the same time, will Datatables be able to know by himself what is where and take the right one?

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    I would just use data. mData is legacy and you don't need it.

    Basically what that error is saying is that your columns.data structure does not match the structure of the data you are applying. Without being able to see some real code snippets and data its hard to say what the problem is.

    Kevin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1
    edited May 2018

    Columns.data looks this this :

    [{data: "A", mData: "A"}, {data: "B", mData: "B"}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
    

    And the data :

    [Array(13), Array(13), Array(13), Array(13), Array(13), Array(13), Array(13), Array(13), Array(13), Array(13), Array(13),.. etc]
    

    Each array containing :

    ["Stuff3", "Stuff3", "Stuff3", "886 ", "100.00 %", "0 ", "28 122.30 €", "31.74 €", "36 058.12 €", "40.70 €", "7935.82 €", "1.28", "22.01 %"]
    

    Something like the above. Did that help?

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Looks like you are using array based data, not object based. So you don'e want to use columns.data. This page describes the differences:
    https://datatables.net/manual/data/#Data-source-types

    Kevin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    I don't use columns.data? But I do have to tell him what my columns (headers) are, what should I do then? x)

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    In your Datatalbes init code are you doing something like this:

    var table = $('#example').DataTable({
       columns: columns,
    });
    

    Which is applying this:
    [{data: "A", mData: "A"}, {data: "B", mData: "B"}....

    Here is an example with ajax and arrays:
    https://datatables.net/examples/ajax/simple.html

    No column definitions. Datatables uses the thead of the table defined in HTML for the column structure.

    Kevin

This discussion has been closed.