Mismatch in the number of fields

Mismatch in the number of fields

akshay3004akshay3004 Posts: 7Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
I am fetching data from a PHP Backend using the fnServerData option. For some reason, while drawing the table, one more column is being expected. I get this popup: "DataTables warning (table id = 'summary'): Requested unknown parameter '13' from the data source for row 0". I just have 13 columns so parameter 13 shouldn't even be there. After investigating further, I saw that before sending the data to fnCallback there were 13 fields for every row and on returning there were 14. Any ideas regarding what I could be doing wrong?

[code]
"fnServerData": (sSource, aoData, fnCallback) ->
$.getJSON(sSource, aoData, (json) ->
for data in json.aaData
len = data.length
console.log len //output 13
fnCallback(json)
)
"fnDrawCallback": (oSettings) ->
table = that.$("#summary").dataTable()
cols = table.fnSettings().aoColumns.length
console.log cols //output 14
col = 0
while col < cols
if that.shownFields.indexOf(col) == -1
table.fnSetColumnVis(col, false)
else
table.fnSetColumnVis(col, true)
col++
[/code]

variable shownfields has been initialized with [0,1,2,3,4,5,6]

Replies

  • essexstephessexsteph Posts: 57Questions: 0Answers: 0
    I think that when you start col at 0 and count up to 13 (i.e. < 14) that gives you 14 iterations over the while loop, i.e. col = 0, col = 1, ..., col =13. Try changing line 12 above to col = 1.

    Steph
  • akshay3004akshay3004 Posts: 7Questions: 0Answers: 0
    Nope didn't work
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    http://datatables.net/faqs#unknown_parameter

    Also see http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read .

    A test case would be needed to see what is going wrong.

    My guess is that there are 14 columns in the HTML. But without being able to see it, I really don;t know.

    Allan
This discussion has been closed.