Requested Unknown Parameter - '[object Object]'

Requested Unknown Parameter - '[object Object]'

DalderDalder Posts: 30Questions: 12Answers: 1

Hello there,

I'm having a bit of trouble when trying to add new rows to my table.

Please see this example I put together: http://live.datatables.net/jeribeba/1/

If you press the "Receive Data" button you will be met with the following error:

"DataTables warning: table id=example - Requested unknown parameter '[object Object]' for row 5, column 3. For more information about this error, please see http://datatables.net/tn/4"

This is exactly the same error I get when I try and do something similar locally.

Can someone please take a look and let me know what the issue is?

Should you need any more information please let me know.

Thanks,

Dan

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Did you follow the diagnostics at the "more information" link?

  • DalderDalder Posts: 30Questions: 12Answers: 1
    edited June 2017

    Yes I did.

    Swapping the values result in the same error.
    Logging the values shows that it is correct and not coming across as undefined/null etc.

    In my actual table there are values after the problem column also, which get populated correctly.

    It looks like the sort criteria on that column may be to blame, but I don't know why.

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    It looks like the sort criteria on that column may be to blame

    Yup. Because you are using orthogonal data DataTables will store the data in the following form:

    {
        "0": "001",
        "1": "Task #1",
        "2": "100",
        "3": {
            "display": "6th June 10:00",
            "@data-order": "1496739600000"
        },
        "4": "2017/06/06"
    }
    

    If you change the row.add() data structure to look like that it will work nicely.

    The other option is to construct a tr element in the same form as the original rows in the table and feed that into row.add(). DataTables will be happy to take the tr element as well.

    Allan

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    DataTables will be happy

    Hmmm - I wonder if that makes DataTables self-aware... There's a scary thought.

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954
    edited June 2017

    Posted after Allan and my answer wasn't correct :smile:

    Kevin

  • DalderDalder Posts: 30Questions: 12Answers: 1

    Thanks for the explanation allan, I changed my script to the object format you provided and I'm no longer getting the error, but the "display" value doesn't seem to be coming through, it's just showing up as blank? Even if I copy and paste your example straight in as such:

    $('#example').DataTable().row.add({
        "0": "001",
        "1": "Task #1",
        "2": "100",
        "3": {
            "display": "6th June 10:00",
            "@data-order": "1496739600000"
        },
        "4": "2017/06/06"
    }).draw();
    

    It still doesn't come through - any ideas?

    Here's an updated link: http://live.datatables.net/johenazi/1/

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    I'll be honest, I'm not sure why that isn't working! Let me dig through that and I'll get back to you.

    Allan

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    I suspect that there is a bug in this logic. I haven't dug into it yet, but I've made to note to do so.

    In the mean time, to get you up and running, here is how you can do it with a note: http://live.datatables.net/johenazi/5/edit .

    Allan

  • DalderDalder Posts: 30Questions: 12Answers: 1

    Thanks Allan, your temporary fix is doing the trick.

    I'm going to mark this thread as answered and keep my eyes peeled for that bug fix!

    DataTables will be happy :smiley:

This discussion has been closed.