[Resolved] How to use mData and aTargets

[Resolved] How to use mData and aTargets

stangstang Posts: 4Questions: 0Answers: 0
edited March 2014 in General
I am new to DataTables. While I got the simple Ajax example to work (where the JSON file contains just "aaData" and array of multidimensional arrays), I wanted to use mData to set up a more complicated JSON.

Here is the remote URL:
http://stephentang.info/files/index.html

Here is the debug information:
http://debug.datatables.net/ezevol

My HTML table has 6 columns, my dataTables innitialization has 6 mData objects, and my JSON has what I think the server is expecting from this documentation: http://datatables.net/release-datatables/examples/server_side/object_data.html

I'm getting a "Cannot read property 'length' of undefined" in the console. The debugger shows no row data.

Any help would be appreciated.

EDIT: It appears that the aTargets prop has to be used in my case, but I'm confused as to why I would need it in this situation.

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    aTargets _must_ be used in aoColumnDefs. It is not used in aoColumns. It sounds like you want aoColumns in this case since you are defining something for every column.

    See: http://datatables.net/usage/columns

    Allan
  • stangstang Posts: 4Questions: 0Answers: 0
    Allan,
    Thanks for clarifying. I saw aTargets mentioned in the aoColumnDefs definition, but I didn't realize it was mandatory. I had thought the code would auto-detect based on the existing mData objects.
This discussion has been closed.